Skip to content

Commit e6335ed

Browse files
authored
Merge branch 'main' into keep-in-cache
2 parents 0837ee1 + 2673cc8 commit e6335ed

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
* fix keepInCache param in YdbQuery
2+
* added Yson type
23
* add logger as Ydb config
34
* added snapshot mode in noninteractive transaction
45

src/QueryResult.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ protected function fillRows($rows)
192192
}
193193
switch ($column['type'])
194194
{
195+
case 'YSON':
195196
case 'STRING':
196197
$_row[$column['name']] = base64_decode($value);
197198
break;

src/Traits/TypeValueHelpersTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
use YdbPlatform\Ydb\Types\DatetimeType;
4040
use YdbPlatform\Ydb\Types\TimestampType;
4141
use YdbPlatform\Ydb\Contracts\TypeContract;
42+
use YdbPlatform\Ydb\Types\YsonType;
4243

4344
trait TypeValueHelpersTrait
4445
{
@@ -142,7 +143,7 @@ public function valueOfType($value, $type)
142143
case 'STRING': return new StringType($value);
143144
case 'TEXT':
144145
case 'UTF8': return new Utf8Type($value);
145-
// case 'YSON': return new StringValue(); // not implemented
146+
case 'YSON': return new YsonType($value); // not implemented
146147
case 'JSON': return new JsonType($value);
147148
case 'UUID': return new StringType($value);
148149
}

src/Types/YsonType.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace YdbPlatform\Ydb\Types;
4+
5+
class YsonType extends AbstractType
6+
{
7+
/**
8+
* @inherit
9+
*/
10+
protected $ydb_key_name = 'bytes_value';
11+
12+
/**
13+
* @inherit
14+
*/
15+
protected $ydb_type = 'Yson';
16+
17+
/**
18+
* @inherit
19+
*/
20+
protected function getYqlString()
21+
{
22+
return 'Yson(@@' . $this->value . '@@)';
23+
}
24+
}

tests/CheckTypeTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ public function testCheckTypesInDeclare(){
4545
];
4646

4747
$checkTypes = [
48+
"Yson" => [
49+
"class" => YsonType::class,
50+
"values" => [
51+
"<a=b>c"
52+
]
53+
],
4854
"Bool" => [
4955
"class" => BoolType::class,
5056
"values" => [

0 commit comments

Comments
 (0)