Skip to content

Commit 9bc0756

Browse files
no message
1 parent 7d8683c commit 9bc0756

18 files changed

+90
-90
lines changed

tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbAggTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ protected function getStringFunctions(): array
1919
#[Test]
2020
public function can_aggregate_single_row_to_jsonb(): void
2121
{
22-
$dql = 'SELECT JSONB_AGG(t.object1) as result
22+
$dql = 'SELECT JSONB_AGG(t.jsonObject1) as result
2323
FROM Fixtures\MartinGeorgiev\Doctrine\Entity\ContainsJsons t
2424
WHERE t.id = 1';
2525
$result = $this->executeDqlQuery($dql);
@@ -38,7 +38,7 @@ public function can_aggregate_single_row_to_jsonb(): void
3838
#[Test]
3939
public function can_aggregate_multiple_rows_to_jsonb(): void
4040
{
41-
$dql = 'SELECT JSONB_AGG(t.object1) as result
41+
$dql = 'SELECT JSONB_AGG(t.jsonObject1) as result
4242
FROM Fixtures\MartinGeorgiev\Doctrine\Entity\ContainsJsons t
4343
WHERE t.id IN (1, 2)';
4444
$result = $this->executeDqlQuery($dql);

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonEachTextTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ protected function getStringFunctions(): array
1919
protected function getExpectedSqlStatements(): array
2020
{
2121
return [
22-
'expands json object into text key-value pairs' => 'SELECT json_each_text(c0_.object1) AS sclr_0 FROM ContainsJsons c0_',
22+
'expands json object into text key-value pairs' => 'SELECT json_each_text(c0_.jsonObject1) AS sclr_0 FROM ContainsJsons c0_',
2323
];
2424
}
2525

2626
protected function getDqlStatements(): array
2727
{
2828
return [
29-
'expands json object into text key-value pairs' => \sprintf('SELECT JSON_EACH_TEXT(e.object1) FROM %s e', ContainsJsons::class),
29+
'expands json object into text key-value pairs' => \sprintf('SELECT JSON_EACH_TEXT(e.jsonObject1) FROM %s e', ContainsJsons::class),
3030
];
3131
}
3232
}

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonExistsTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ protected function getStringFunctions(): array
1919
protected function getExpectedSqlStatements(): array
2020
{
2121
return [
22-
'checks if simple path exists' => "SELECT json_exists(c0_.object1, '$.name') AS sclr_0 FROM ContainsJsons c0_",
23-
'checks if nested path exists' => "SELECT json_exists(c0_.object1, '$.address.city') AS sclr_0 FROM ContainsJsons c0_",
24-
'checks if array element exists' => "SELECT json_exists(c0_.object1, '$.items[0]') AS sclr_0 FROM ContainsJsons c0_",
25-
'checks if deeply nested array element exists' => "SELECT json_exists(c0_.object1, '$.users[0].addresses[0].street') AS sclr_0 FROM ContainsJsons c0_",
22+
'checks if simple path exists' => "SELECT json_exists(c0_.jsonObject1, '$.name') AS sclr_0 FROM ContainsJsons c0_",
23+
'checks if nested path exists' => "SELECT json_exists(c0_.jsonObject1, '$.address.city') AS sclr_0 FROM ContainsJsons c0_",
24+
'checks if array element exists' => "SELECT json_exists(c0_.jsonObject1, '$.items[0]') AS sclr_0 FROM ContainsJsons c0_",
25+
'checks if deeply nested array element exists' => "SELECT json_exists(c0_.jsonObject1, '$.users[0].addresses[0].street') AS sclr_0 FROM ContainsJsons c0_",
2626
];
2727
}
2828

2929
protected function getDqlStatements(): array
3030
{
3131
return [
32-
'checks if simple path exists' => \sprintf("SELECT JSON_EXISTS(e.object1, '$.name') FROM %s e", ContainsJsons::class),
33-
'checks if nested path exists' => \sprintf("SELECT JSON_EXISTS(e.object1, '$.address.city') FROM %s e", ContainsJsons::class),
34-
'checks if array element exists' => \sprintf("SELECT JSON_EXISTS(e.object1, '$.items[0]') FROM %s e", ContainsJsons::class),
35-
'checks if deeply nested array element exists' => \sprintf("SELECT JSON_EXISTS(e.object1, '$.users[0].addresses[0].street') FROM %s e", ContainsJsons::class),
32+
'checks if simple path exists' => \sprintf("SELECT JSON_EXISTS(e.jsonObject1, '$.name') FROM %s e", ContainsJsons::class),
33+
'checks if nested path exists' => \sprintf("SELECT JSON_EXISTS(e.jsonObject1, '$.address.city') FROM %s e", ContainsJsons::class),
34+
'checks if array element exists' => \sprintf("SELECT JSON_EXISTS(e.jsonObject1, '$.items[0]') FROM %s e", ContainsJsons::class),
35+
'checks if deeply nested array element exists' => \sprintf("SELECT JSON_EXISTS(e.jsonObject1, '$.users[0].addresses[0].street') FROM %s e", ContainsJsons::class),
3636
];
3737
}
3838
}

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsIntegerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ protected function getStringFunctions(): array
2121
protected function getExpectedSqlStatements(): array
2222
{
2323
return [
24-
'extracts field as integer' => "SELECT CAST(c0_.object1 ->> 'rank' as BIGINT) AS sclr_0 FROM ContainsJsons c0_",
25-
'extracts array element as integer' => 'SELECT CAST(c0_.object1 ->> 0 as BIGINT) AS sclr_0 FROM ContainsJsons c0_',
26-
'extracts nested array element as integer' => "SELECT CAST((c0_.object1 -> 'scores') ->> 1 as BIGINT) AS sclr_0 FROM ContainsJsons c0_",
24+
'extracts field as integer' => "SELECT CAST(c0_.jsonObject1 ->> 'rank' as BIGINT) AS sclr_0 FROM ContainsJsons c0_",
25+
'extracts array element as integer' => 'SELECT CAST(c0_.jsonObject1 ->> 0 as BIGINT) AS sclr_0 FROM ContainsJsons c0_',
26+
'extracts nested array element as integer' => "SELECT CAST((c0_.jsonObject1 -> 'scores') ->> 1 as BIGINT) AS sclr_0 FROM ContainsJsons c0_",
2727
];
2828
}
2929

3030
protected function getDqlStatements(): array
3131
{
3232
return [
33-
'extracts field as integer' => \sprintf("SELECT JSON_GET_FIELD_AS_INTEGER(e.object1, 'rank') FROM %s e", ContainsJsons::class),
34-
'extracts array element as integer' => \sprintf('SELECT JSON_GET_FIELD_AS_INTEGER(e.object1, 0) FROM %s e', ContainsJsons::class),
35-
'extracts nested array element as integer' => \sprintf("SELECT JSON_GET_FIELD_AS_INTEGER(JSON_GET_FIELD(e.object1, 'scores'), 1) FROM %s e", ContainsJsons::class),
33+
'extracts field as integer' => \sprintf("SELECT JSON_GET_FIELD_AS_INTEGER(e.jsonObject1, 'rank') FROM %s e", ContainsJsons::class),
34+
'extracts array element as integer' => \sprintf('SELECT JSON_GET_FIELD_AS_INTEGER(e.jsonObject1, 0) FROM %s e', ContainsJsons::class),
35+
'extracts nested array element as integer' => \sprintf("SELECT JSON_GET_FIELD_AS_INTEGER(JSON_GET_FIELD(e.jsonObject1, 'scores'), 1) FROM %s e", ContainsJsons::class),
3636
];
3737
}
3838
}

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsTextTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ protected function getStringFunctions(): array
2121
protected function getExpectedSqlStatements(): array
2222
{
2323
return [
24-
'extracts field as text' => "SELECT (c0_.object1 ->> 'country') AS sclr_0 FROM ContainsJsons c0_",
25-
'extracts array element as text' => 'SELECT (c0_.object1 ->> 0) AS sclr_0 FROM ContainsJsons c0_',
26-
'extracts nested array element as text' => "SELECT ((c0_.object1 -> 'tags') ->> 1) AS sclr_0 FROM ContainsJsons c0_",
24+
'extracts field as text' => "SELECT (c0_.jsonObject1 ->> 'country') AS sclr_0 FROM ContainsJsons c0_",
25+
'extracts array element as text' => 'SELECT (c0_.jsonObject1 ->> 0) AS sclr_0 FROM ContainsJsons c0_',
26+
'extracts nested array element as text' => "SELECT ((c0_.jsonObject1 -> 'tags') ->> 1) AS sclr_0 FROM ContainsJsons c0_",
2727
];
2828
}
2929

3030
protected function getDqlStatements(): array
3131
{
3232
return [
33-
'extracts field as text' => \sprintf("SELECT JSON_GET_FIELD_AS_TEXT(e.object1, 'country') FROM %s e", ContainsJsons::class),
34-
'extracts array element as text' => \sprintf('SELECT JSON_GET_FIELD_AS_TEXT(e.object1, 0) FROM %s e', ContainsJsons::class),
35-
'extracts nested array element as text' => \sprintf("SELECT JSON_GET_FIELD_AS_TEXT(JSON_GET_FIELD(e.object1, 'tags'), 1) FROM %s e", ContainsJsons::class),
33+
'extracts field as text' => \sprintf("SELECT JSON_GET_FIELD_AS_TEXT(e.jsonObject1, 'country') FROM %s e", ContainsJsons::class),
34+
'extracts array element as text' => \sprintf('SELECT JSON_GET_FIELD_AS_TEXT(e.jsonObject1, 0) FROM %s e', ContainsJsons::class),
35+
'extracts nested array element as text' => \sprintf("SELECT JSON_GET_FIELD_AS_TEXT(JSON_GET_FIELD(e.jsonObject1, 'tags'), 1) FROM %s e", ContainsJsons::class),
3636
];
3737
}
3838
}

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ protected function getStringFunctions(): array
1919
protected function getExpectedSqlStatements(): array
2020
{
2121
return [
22-
'extracts top-level field from json' => "SELECT (c0_.object1 -> 'key') AS sclr_0 FROM ContainsJsons c0_",
23-
'extracts nested field from json' => "SELECT ((c0_.object1 -> 'nested') -> 'key') AS sclr_0 FROM ContainsJsons c0_",
24-
'extracts array element by index' => 'SELECT (c0_.object1 -> 0) AS sclr_0 FROM ContainsJsons c0_',
25-
'extracts nested array element by index' => "SELECT ((c0_.object1 -> 'tags') -> 1) AS sclr_0 FROM ContainsJsons c0_",
26-
'extracts field from array element by index' => "SELECT ((c0_.object1 -> 0) -> 'name') AS sclr_0 FROM ContainsJsons c0_",
22+
'extracts top-level field from json' => "SELECT (c0_.jsonObject1 -> 'key') AS sclr_0 FROM ContainsJsons c0_",
23+
'extracts nested field from json' => "SELECT ((c0_.jsonObject1 -> 'nested') -> 'key') AS sclr_0 FROM ContainsJsons c0_",
24+
'extracts array element by index' => 'SELECT (c0_.jsonObject1 -> 0) AS sclr_0 FROM ContainsJsons c0_',
25+
'extracts nested array element by index' => "SELECT ((c0_.jsonObject1 -> 'tags') -> 1) AS sclr_0 FROM ContainsJsons c0_",
26+
'extracts field from array element by index' => "SELECT ((c0_.jsonObject1 -> 0) -> 'name') AS sclr_0 FROM ContainsJsons c0_",
2727
];
2828
}
2929

3030
protected function getDqlStatements(): array
3131
{
3232
return [
33-
'extracts top-level field from json' => \sprintf("SELECT JSON_GET_FIELD(e.object1, 'key') FROM %s e", ContainsJsons::class),
34-
'extracts nested field from json' => \sprintf("SELECT JSON_GET_FIELD(JSON_GET_FIELD(e.object1, 'nested'), 'key') FROM %s e", ContainsJsons::class),
35-
'extracts array element by index' => \sprintf('SELECT JSON_GET_FIELD(e.object1, 0) FROM %s e', ContainsJsons::class),
36-
'extracts nested array element by index' => \sprintf("SELECT JSON_GET_FIELD(JSON_GET_FIELD(e.object1, 'tags'), 1) FROM %s e", ContainsJsons::class),
37-
'extracts field from array element by index' => \sprintf("SELECT JSON_GET_FIELD(JSON_GET_FIELD(e.object1, 0), 'name') FROM %s e", ContainsJsons::class),
33+
'extracts top-level field from json' => \sprintf("SELECT JSON_GET_FIELD(e.jsonObject1, 'key') FROM %s e", ContainsJsons::class),
34+
'extracts nested field from json' => \sprintf("SELECT JSON_GET_FIELD(JSON_GET_FIELD(e.jsonObject1, 'nested'), 'key') FROM %s e", ContainsJsons::class),
35+
'extracts array element by index' => \sprintf('SELECT JSON_GET_FIELD(e.jsonObject1, 0) FROM %s e', ContainsJsons::class),
36+
'extracts nested array element by index' => \sprintf("SELECT JSON_GET_FIELD(JSON_GET_FIELD(e.jsonObject1, 'tags'), 1) FROM %s e", ContainsJsons::class),
37+
'extracts field from array element by index' => \sprintf("SELECT JSON_GET_FIELD(JSON_GET_FIELD(e.jsonObject1, 0), 'name') FROM %s e", ContainsJsons::class),
3838
];
3939
}
4040
}

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetObjectAsTextTest.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,26 @@ protected function getStringFunctions(): array
1919
protected function getExpectedSqlStatements(): array
2020
{
2121
return [
22-
'extracts top-level object as text' => "SELECT (c0_.object1 #>> '{metadata}') AS sclr_0 FROM ContainsJsons c0_",
23-
'extracts nested object as text' => "SELECT (c0_.object1 #>> '{user,address}') AS sclr_0 FROM ContainsJsons c0_",
24-
'extracts array element as text' => "SELECT (c0_.object1 #>> '{items,0}') AS sclr_0 FROM ContainsJsons c0_",
25-
'extracts deeply nested object as text' => "SELECT (c0_.object1 #>> '{store,departments,main}') AS sclr_0 FROM ContainsJsons c0_",
26-
'extracts from complex path as text' => "SELECT (c0_.object1 #>> '{data,users,0,profile}') AS sclr_0 FROM ContainsJsons c0_",
27-
'extracts last array element as text' => "SELECT (c0_.object1 #>> '{records,-1}') AS sclr_0 FROM ContainsJsons c0_",
28-
'extracts nested array element as text' => "SELECT (c0_.object1 #>> '{categories,2,description}') AS sclr_0 FROM ContainsJsons c0_",
22+
'extracts top-level object as text' => "SELECT (c0_.jsonObject1 #>> '{metadata}') AS sclr_0 FROM ContainsJsons c0_",
23+
'extracts nested object as text' => "SELECT (c0_.jsonObject1 #>> '{user,address}') AS sclr_0 FROM ContainsJsons c0_",
24+
'extracts array element as text' => "SELECT (c0_.jsonObject1 #>> '{items,0}') AS sclr_0 FROM ContainsJsons c0_",
25+
'extracts deeply nested object as text' => "SELECT (c0_.jsonObject1 #>> '{store,departments,main}') AS sclr_0 FROM ContainsJsons c0_",
26+
'extracts from complex path as text' => "SELECT (c0_.jsonObject1 #>> '{data,users,0,profile}') AS sclr_0 FROM ContainsJsons c0_",
27+
'extracts last array element as text' => "SELECT (c0_.jsonObject1 #>> '{records,-1}') AS sclr_0 FROM ContainsJsons c0_",
28+
'extracts nested array element as text' => "SELECT (c0_.jsonObject1 #>> '{categories,2,description}') AS sclr_0 FROM ContainsJsons c0_",
2929
];
3030
}
3131

3232
protected function getDqlStatements(): array
3333
{
3434
return [
35-
'extracts top-level object as text' => \sprintf("SELECT JSON_GET_OBJECT_AS_TEXT(e.object1, '{metadata}') FROM %s e", ContainsJsons::class),
36-
'extracts nested object as text' => \sprintf("SELECT JSON_GET_OBJECT_AS_TEXT(e.object1, '{user,address}') FROM %s e", ContainsJsons::class),
37-
'extracts array element as text' => \sprintf("SELECT JSON_GET_OBJECT_AS_TEXT(e.object1, '{items,0}') FROM %s e", ContainsJsons::class),
38-
'extracts deeply nested object as text' => \sprintf("SELECT JSON_GET_OBJECT_AS_TEXT(e.object1, '{store,departments,main}') FROM %s e", ContainsJsons::class),
39-
'extracts from complex path as text' => \sprintf("SELECT JSON_GET_OBJECT_AS_TEXT(e.object1, '{data,users,0,profile}') FROM %s e", ContainsJsons::class),
40-
'extracts last array element as text' => \sprintf("SELECT JSON_GET_OBJECT_AS_TEXT(e.object1, '{records,-1}') FROM %s e", ContainsJsons::class),
41-
'extracts nested array element as text' => \sprintf("SELECT JSON_GET_OBJECT_AS_TEXT(e.object1, '{categories,2,description}') FROM %s e", ContainsJsons::class),
35+
'extracts top-level object as text' => \sprintf("SELECT JSON_GET_OBJECT_AS_TEXT(e.jsonObject1, '{metadata}') FROM %s e", ContainsJsons::class),
36+
'extracts nested object as text' => \sprintf("SELECT JSON_GET_OBJECT_AS_TEXT(e.jsonObject1, '{user,address}') FROM %s e", ContainsJsons::class),
37+
'extracts array element as text' => \sprintf("SELECT JSON_GET_OBJECT_AS_TEXT(e.jsonObject1, '{items,0}') FROM %s e", ContainsJsons::class),
38+
'extracts deeply nested object as text' => \sprintf("SELECT JSON_GET_OBJECT_AS_TEXT(e.jsonObject1, '{store,departments,main}') FROM %s e", ContainsJsons::class),
39+
'extracts from complex path as text' => \sprintf("SELECT JSON_GET_OBJECT_AS_TEXT(e.jsonObject1, '{data,users,0,profile}') FROM %s e", ContainsJsons::class),
40+
'extracts last array element as text' => \sprintf("SELECT JSON_GET_OBJECT_AS_TEXT(e.jsonObject1, '{records,-1}') FROM %s e", ContainsJsons::class),
41+
'extracts nested array element as text' => \sprintf("SELECT JSON_GET_OBJECT_AS_TEXT(e.jsonObject1, '{categories,2,description}') FROM %s e", ContainsJsons::class),
4242
];
4343
}
4444
}

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetObjectTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ protected function getStringFunctions(): array
1919
protected function getExpectedSqlStatements(): array
2020
{
2121
return [
22-
'extracts JSON object at specified path' => "SELECT (c0_.object1 #> '{residency}') AS sclr_0 FROM ContainsJsons c0_",
22+
'extracts JSON object at specified path' => "SELECT (c0_.jsonObject1 #> '{residency}') AS sclr_0 FROM ContainsJsons c0_",
2323
];
2424
}
2525

2626
protected function getDqlStatements(): array
2727
{
2828
return [
29-
'extracts JSON object at specified path' => \sprintf("SELECT JSON_GET_OBJECT(e.object1, '{residency}') FROM %s e", ContainsJsons::class),
29+
'extracts JSON object at specified path' => \sprintf("SELECT JSON_GET_OBJECT(e.jsonObject1, '{residency}') FROM %s e", ContainsJsons::class),
3030
];
3131
}
3232
}

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonObjectKeysTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ protected function getStringFunctions(): array
1919
protected function getExpectedSqlStatements(): array
2020
{
2121
return [
22-
'SELECT json_object_keys(c0_.object1) AS sclr_0 FROM ContainsJsons c0_',
22+
'SELECT json_object_keys(c0_.jsonObject1) AS sclr_0 FROM ContainsJsons c0_',
2323
];
2424
}
2525

2626
protected function getDqlStatements(): array
2727
{
2828
return [
29-
\sprintf('SELECT JSON_OBJECT_KEYS(e.object1) FROM %s e', ContainsJsons::class),
29+
\sprintf('SELECT JSON_OBJECT_KEYS(e.jsonObject1) FROM %s e', ContainsJsons::class),
3030
];
3131
}
3232
}

0 commit comments

Comments
 (0)