Skip to content

Commit

Permalink
Add explicit order_by information to translation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljharvey committed Nov 6, 2023
1 parent efeda8c commit 171182d
Show file tree
Hide file tree
Showing 15 changed files with 267 additions and 232 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@
}
},
"limit": 5,
"order_by": {
"elements": [
{
"order_direction": "asc",
"target": {
"type": "column",
"name": "AlbumId",
"path": []
}
}
]
},
"offset": 3,
"aggregates": {
"how_many_albums": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,19 @@
}
}
},
"limit": 5
"limit": 5,
"order_by": {
"elements": [
{
"order_direction": "asc",
"target": {
"type": "column",
"name": "ArtistId",
"path": []
}
}
]
}
},
"arguments": {},
"collection_relationships": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,19 @@
}
},
"limit": 5,
"offset": 1
"offset": 1,
"order_by": {
"elements": [
{
"order_direction": "asc",
"target": {
"type": "column",
"name": "ArtistId",
"path": []
}
}
]
}
},
"arguments": {},
"collection_relationships": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@
},
"limit": 5,
"offset": 100,

"order_by": {
"elements": [
{
"order_direction": "asc",
"target": {
"type": "column",
"name": "Id",
"path": []
}
}
]
},
"where": {
"type": "not",
"expression": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@
}
},
"limit": 5,
"offset": 3
"offset": 3,
"order_by": {
"elements": [
{
"order_direction": "asc",
"target": {
"type": "column",
"name": "AlbumId",
"path": []
}
}
]
}
},
"arguments": {},
"collection_relationships": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"schemaName": "public",
"tableName": "Album",
"columns": {
"AlbumId": {
"name": "AlbumId",
"type": "int"
},
"Title": {
"name": "Title",
"type": "varchar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,19 @@
}
}
},
"limit": 5
"limit": 5,
"order_by": {
"elements": [
{
"order_direction": "asc",
"target": {
"type": "column",
"name": "ArtistId",
"path": []
}
}
]
}
},
"arguments": {},
"collection_relationships": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,19 @@
}
}
},
"limit": 5
"limit": 5,
"order_by": {
"elements": [
{
"order_direction": "asc",
"target": {
"type": "column",
"name": "AlbumId",
"path": []
}
}
]
}
},
"arguments": {},
"collection_relationships": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,51 @@ source: crates/query-engine/translation/tests/tests.rs
expression: result
---
SELECT
row_to_json("%9_universe") AS "universe"
ISNULL([10_rows].[rows], '[]') AS [rows]
FROM
(
SELECT
*
JSON_QUERY([1_RELATIONSHIP_albums].[json], '$') AS [albums],
JSON_QUERY([2_RELATIONSHIP_Albums].[json], '$') AS [Albums]
FROM
(
[public].[Artist] AS [0_Artist]
OUTER APPLY (
SELECT
coalesce(json_agg(row_to_json("%10_rows")), '[]') AS "rows"
ISNULL([4_rows].[row_json], '[]') AS [rows]
FROM
(
SELECT
"%1_RELATIONSHIP_albums"."albums" AS "albums",
"%2_RELATIONSHIP_Albums"."Albums" AS "Albums"
[3_Album].[Title] AS [title]
FROM
"public"."Artist" AS "%0_Artist"
LEFT OUTER JOIN LATERAL (
SELECT
row_to_json("%1_RELATIONSHIP_albums") AS "albums"
FROM
(
SELECT
*
FROM
(
SELECT
coalesce(json_agg(row_to_json("%4_rows")), '[]') AS "rows"
FROM
(
SELECT
"%3_Album"."Title" AS "title"
FROM
"public"."Album" AS "%3_Album"
WHERE
("%0_Artist"."ArtistId" = "%3_Album"."ArtistId")
) AS "%4_rows"
) AS "%4_rows"
) AS "%1_RELATIONSHIP_albums"
) AS "%1_RELATIONSHIP_albums" ON ('true')
LEFT OUTER JOIN LATERAL (
SELECT
row_to_json("%2_RELATIONSHIP_Albums") AS "Albums"
FROM
(
SELECT
*
FROM
(
SELECT
coalesce(json_agg(row_to_json("%7_rows")), '[]') AS "rows"
FROM
(
SELECT
"%6_Album"."Title" AS "title"
FROM
"public"."Album" AS "%6_Album"
WHERE
("%0_Artist"."ArtistId" = "%6_Album"."ArtistId")
) AS "%7_rows"
) AS "%7_rows"
) AS "%2_RELATIONSHIP_Albums"
) AS "%2_RELATIONSHIP_Albums" ON ('true')
LIMIT
5
) AS "%10_rows"
) AS "%10_rows"
) AS "%9_universe"
[public].[Album] AS [3_Album]
WHERE
([0_Artist].[ArtistId] = [3_Album].[ArtistId]) FOR JSON PATH,
INCLUDE_NULL_VALUES
) AS [4_rows]([row_json]) FOR JSON PATH,
INCLUDE_NULL_VALUES,
WITHOUT_ARRAY_WRAPPER
) AS [1_RELATIONSHIP_albums]([json])
OUTER APPLY (
SELECT
ISNULL([7_rows].[row_json], '[]') AS [rows]
FROM
(
SELECT
[6_Album].[Title] AS [title]
FROM
[public].[Album] AS [6_Album]
WHERE
([0_Artist].[ArtistId] = [6_Album].[ArtistId]) FOR JSON PATH,
INCLUDE_NULL_VALUES
) AS [7_rows]([row_json]) FOR JSON PATH,
INCLUDE_NULL_VALUES,
WITHOUT_ARRAY_WRAPPER
) AS [2_RELATIONSHIP_Albums]([json])
ORDER BY
[0_Artist].[ArtistId] ASC OFFSET 0 ROWS FETCH NEXT 5 ROWS ONLY FOR JSON PATH,
INCLUDE_NULL_VALUES
) AS [10_rows]([rows]) FOR JSON PATH,
INCLUDE_NULL_VALUES,
WITHOUT_ARRAY_WRAPPER

[]
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,44 @@ source: crates/query-engine/translation/tests/tests.rs
expression: result
---
SELECT
row_to_json("%1_universe") AS "universe"
JSON_QUERY(ISNULL([2_rows].[rows], '[]'), '$.rows') AS [rows],
JSON_QUERY(
JSON_VALUE([3_aggregates].[aggregates], '$.aggregates'),
'$'
) AS [aggregates]
FROM
(
SELECT
*
FROM
(
SELECT
coalesce(json_agg(row_to_json("%2_rows")), '[]') AS "rows"
[0_Album].[Title] AS [Title]
FROM
(
SELECT
"%0_Album"."Title" AS "Title"
FROM
"public"."Album" AS "%0_Album"
LIMIT
5 OFFSET 3
) AS "%2_rows"
) AS "%2_rows"
CROSS JOIN (
[public].[Album] AS [0_Album]
ORDER BY
[0_Album].[AlbumId] ASC OFFSET 3 ROWS FETCH NEXT 5 ROWS ONLY FOR JSON PATH,
INCLUDE_NULL_VALUES
) AS [1_universe]([rows]) FOR JSON PATH,
INCLUDE_NULL_VALUES,
WITHOUT_ARRAY_WRAPPER
) AS [2_rows]([rows])
CROSS JOIN (
SELECT
*
FROM
(
SELECT
coalesce(row_to_json("%3_aggregates"), '[]') AS "aggregates"
COUNT(*) AS [how_many_albums]
FROM
(
SELECT
COUNT(*) AS "how_many_albums"
FROM
"public"."Album" AS "%0_Album"
) AS "%3_aggregates"
) AS "%3_aggregates"
) AS "%1_universe"
[public].[Album] AS [0_Album] FOR JSON PATH,
INCLUDE_NULL_VALUES,
WITHOUT_ARRAY_WRAPPER
) AS [3_aggregates]([aggregates]) FOR JSON PATH,
INCLUDE_NULL_VALUES,
WITHOUT_ARRAY_WRAPPER
) AS [3_aggregates]([aggregates]) FOR JSON PATH,
INCLUDE_NULL_VALUES,
WITHOUT_ARRAY_WRAPPER

[]
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,18 @@ source: crates/query-engine/translation/tests/tests.rs
expression: result
---
SELECT
row_to_json("%1_universe") AS "universe"
ISNULL([2_rows].[rows], '[]') AS [rows]
FROM
(
SELECT
*
[0_Album].[Title] AS [Title]
FROM
(
SELECT
coalesce(json_agg(row_to_json("%2_rows")), '[]') AS "rows"
FROM
(
SELECT
"%0_Album"."Title" AS "Title"
FROM
"public"."Album" AS "%0_Album"
LIMIT
5 OFFSET 3
) AS "%2_rows"
) AS "%2_rows"
) AS "%1_universe"
[public].[Album] AS [0_Album]
ORDER BY
[0_Album].[AlbumId] ASC OFFSET 3 ROWS FETCH NEXT 5 ROWS ONLY FOR JSON PATH,
INCLUDE_NULL_VALUES
) AS [2_rows]([rows]) FOR JSON PATH,
INCLUDE_NULL_VALUES,
WITHOUT_ARRAY_WRAPPER

[]
Loading

0 comments on commit 171182d

Please sign in to comment.