From f6f26e64c1dd9cd37e956132db6811c0c2fbe288 Mon Sep 17 00:00:00 2001 From: Daniel Harvey Date: Mon, 6 Nov 2023 17:07:59 +0000 Subject: [PATCH] Add explicit order_by information to translation tests --- .../aggregate_count_albums/request.json | 12 +++ .../dup_array_relationship/request.json | 14 ++- .../nested_aggregates/request.json | 14 ++- .../select_where_not_null/request.json | 13 +++ .../select_with_limit/request.json | 14 ++- .../goldenfiles/select_with_limit/tables.json | 4 + .../simple_array_relationship/request.json | 14 ++- .../simple_object_relationship/request.json | 14 ++- .../tests__dup_array_relationship.snap | 95 ++++++++----------- .../tests__it_aggregate_count_albums.snap | 50 ++++++---- .../tests__it_converts_select_with_limit.snap | 25 ++--- .../tests__it_select_where_not_null.snap | 29 +++--- .../tests__it_simple_array_relationship.snap | 54 ++++------- .../tests__it_simple_object_relationship.snap | 54 ++++------- .../snapshots/tests__nested_aggregates.snap | 93 +++++++++--------- 15 files changed, 267 insertions(+), 232 deletions(-) diff --git a/crates/query-engine/translation/tests/goldenfiles/aggregate_count_albums/request.json b/crates/query-engine/translation/tests/goldenfiles/aggregate_count_albums/request.json index bff53c44..1206446e 100644 --- a/crates/query-engine/translation/tests/goldenfiles/aggregate_count_albums/request.json +++ b/crates/query-engine/translation/tests/goldenfiles/aggregate_count_albums/request.json @@ -9,6 +9,18 @@ } }, "limit": 5, + "order_by": { + "elements": [ + { + "order_direction": "asc", + "target": { + "type": "column", + "name": "AlbumId", + "path": [] + } + } + ] + }, "offset": 3, "aggregates": { "how_many_albums": { diff --git a/crates/query-engine/translation/tests/goldenfiles/dup_array_relationship/request.json b/crates/query-engine/translation/tests/goldenfiles/dup_array_relationship/request.json index 15a25b6b..9565db39 100644 --- a/crates/query-engine/translation/tests/goldenfiles/dup_array_relationship/request.json +++ b/crates/query-engine/translation/tests/goldenfiles/dup_array_relationship/request.json @@ -31,7 +31,19 @@ } } }, - "limit": 5 + "limit": 5, + "order_by": { + "elements": [ + { + "order_direction": "asc", + "target": { + "type": "column", + "name": "ArtistId", + "path": [] + } + } + ] + } }, "arguments": {}, "collection_relationships": { diff --git a/crates/query-engine/translation/tests/goldenfiles/nested_aggregates/request.json b/crates/query-engine/translation/tests/goldenfiles/nested_aggregates/request.json index 09ec4eef..163db2d5 100644 --- a/crates/query-engine/translation/tests/goldenfiles/nested_aggregates/request.json +++ b/crates/query-engine/translation/tests/goldenfiles/nested_aggregates/request.json @@ -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": { diff --git a/crates/query-engine/translation/tests/goldenfiles/select_where_not_null/request.json b/crates/query-engine/translation/tests/goldenfiles/select_where_not_null/request.json index 4c70bd90..e240912b 100644 --- a/crates/query-engine/translation/tests/goldenfiles/select_where_not_null/request.json +++ b/crates/query-engine/translation/tests/goldenfiles/select_where_not_null/request.json @@ -10,6 +10,19 @@ }, "limit": 5, "offset": 100, + + "order_by": { + "elements": [ + { + "order_direction": "asc", + "target": { + "type": "column", + "name": "Id", + "path": [] + } + } + ] + }, "where": { "type": "not", "expression": { diff --git a/crates/query-engine/translation/tests/goldenfiles/select_with_limit/request.json b/crates/query-engine/translation/tests/goldenfiles/select_with_limit/request.json index a520de35..5440c71c 100644 --- a/crates/query-engine/translation/tests/goldenfiles/select_with_limit/request.json +++ b/crates/query-engine/translation/tests/goldenfiles/select_with_limit/request.json @@ -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": {} diff --git a/crates/query-engine/translation/tests/goldenfiles/select_with_limit/tables.json b/crates/query-engine/translation/tests/goldenfiles/select_with_limit/tables.json index 5c43b510..cd582bc3 100644 --- a/crates/query-engine/translation/tests/goldenfiles/select_with_limit/tables.json +++ b/crates/query-engine/translation/tests/goldenfiles/select_with_limit/tables.json @@ -4,6 +4,10 @@ "schemaName": "public", "tableName": "Album", "columns": { + "AlbumId": { + "name": "AlbumId", + "type": "int" + }, "Title": { "name": "Title", "type": "varchar" diff --git a/crates/query-engine/translation/tests/goldenfiles/simple_array_relationship/request.json b/crates/query-engine/translation/tests/goldenfiles/simple_array_relationship/request.json index 35e32394..7998ec8a 100644 --- a/crates/query-engine/translation/tests/goldenfiles/simple_array_relationship/request.json +++ b/crates/query-engine/translation/tests/goldenfiles/simple_array_relationship/request.json @@ -17,7 +17,19 @@ } } }, - "limit": 5 + "limit": 5, + "order_by": { + "elements": [ + { + "order_direction": "asc", + "target": { + "type": "column", + "name": "ArtistId", + "path": [] + } + } + ] + } }, "arguments": {}, "collection_relationships": { diff --git a/crates/query-engine/translation/tests/goldenfiles/simple_object_relationship/request.json b/crates/query-engine/translation/tests/goldenfiles/simple_object_relationship/request.json index 692e2213..7761d4d0 100644 --- a/crates/query-engine/translation/tests/goldenfiles/simple_object_relationship/request.json +++ b/crates/query-engine/translation/tests/goldenfiles/simple_object_relationship/request.json @@ -17,7 +17,19 @@ } } }, - "limit": 5 + "limit": 5, + "order_by": { + "elements": [ + { + "order_direction": "asc", + "target": { + "type": "column", + "name": "AlbumId", + "path": [] + } + } + ] + } }, "arguments": {}, "collection_relationships": { diff --git a/crates/query-engine/translation/tests/snapshots/tests__dup_array_relationship.snap b/crates/query-engine/translation/tests/snapshots/tests__dup_array_relationship.snap index d372ddf1..b4ae86da 100644 --- a/crates/query-engine/translation/tests/snapshots/tests__dup_array_relationship.snap +++ b/crates/query-engine/translation/tests/snapshots/tests__dup_array_relationship.snap @@ -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 [] diff --git a/crates/query-engine/translation/tests/snapshots/tests__it_aggregate_count_albums.snap b/crates/query-engine/translation/tests/snapshots/tests__it_aggregate_count_albums.snap index 42fcd4f4..c570e09b 100644 --- a/crates/query-engine/translation/tests/snapshots/tests__it_aggregate_count_albums.snap +++ b/crates/query-engine/translation/tests/snapshots/tests__it_aggregate_count_albums.snap @@ -3,7 +3,11 @@ 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 @@ -11,28 +15,32 @@ FROM 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 [] diff --git a/crates/query-engine/translation/tests/snapshots/tests__it_converts_select_with_limit.snap b/crates/query-engine/translation/tests/snapshots/tests__it_converts_select_with_limit.snap index 61d1d625..5f006e54 100644 --- a/crates/query-engine/translation/tests/snapshots/tests__it_converts_select_with_limit.snap +++ b/crates/query-engine/translation/tests/snapshots/tests__it_converts_select_with_limit.snap @@ -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 [] diff --git a/crates/query-engine/translation/tests/snapshots/tests__it_select_where_not_null.snap b/crates/query-engine/translation/tests/snapshots/tests__it_select_where_not_null.snap index 79098a46..69d7a818 100644 --- a/crates/query-engine/translation/tests/snapshots/tests__it_select_where_not_null.snap +++ b/crates/query-engine/translation/tests/snapshots/tests__it_select_where_not_null.snap @@ -3,27 +3,20 @@ 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" - WHERE - NOT ("%0_Album"."AlbumId" IS NULL) - LIMIT - 5 OFFSET 100 - ) AS "%2_rows" - ) AS "%2_rows" - ) AS "%1_universe" + [public].[Album] AS [0_Album] + WHERE + NOT ([0_Album].[AlbumId] IS NULL) + ORDER BY + [0_Album].[AlbumId] ASC OFFSET 100 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 [] diff --git a/crates/query-engine/translation/tests/snapshots/tests__it_simple_array_relationship.snap b/crates/query-engine/translation/tests/snapshots/tests__it_simple_array_relationship.snap index 18f0114f..18579351 100644 --- a/crates/query-engine/translation/tests/snapshots/tests__it_simple_array_relationship.snap +++ b/crates/query-engine/translation/tests/snapshots/tests__it_simple_array_relationship.snap @@ -3,48 +3,34 @@ source: crates/query-engine/translation/tests/tests.rs expression: result --- SELECT - row_to_json("%5_universe") AS "universe" + ISNULL([6_rows].[rows], '[]') AS [rows] FROM ( SELECT - * + JSON_QUERY([1_RELATIONSHIP_Albums].[json], '$') AS [Albums] FROM - ( + [public].[Artist] AS [0_Artist] + OUTER APPLY ( SELECT - coalesce(json_agg(row_to_json("%6_rows")), '[]') AS "rows" + ISNULL([3_rows].[row_json], '[]') AS [rows] FROM ( SELECT - "%1_RELATIONSHIP_Albums"."Albums" AS "Albums" + [2_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("%3_rows")), '[]') AS "rows" - FROM - ( - SELECT - "%2_Album"."Title" AS "title" - FROM - "public"."Album" AS "%2_Album" - WHERE - ("%0_Artist"."ArtistId" = "%2_Album"."ArtistId") - ) AS "%3_rows" - ) AS "%3_rows" - ) AS "%1_RELATIONSHIP_Albums" - ) AS "%1_RELATIONSHIP_Albums" ON ('true') - LIMIT - 5 - ) AS "%6_rows" - ) AS "%6_rows" - ) AS "%5_universe" + [public].[Album] AS [2_Album] + WHERE + ([0_Artist].[ArtistId] = [2_Album].[ArtistId]) FOR JSON PATH, + INCLUDE_NULL_VALUES + ) AS [3_rows]([row_json]) FOR JSON PATH, + INCLUDE_NULL_VALUES, + WITHOUT_ARRAY_WRAPPER + ) AS [1_RELATIONSHIP_Albums]([json]) + ORDER BY + [0_Artist].[ArtistId] ASC OFFSET 0 ROWS FETCH NEXT 5 ROWS ONLY FOR JSON PATH, + INCLUDE_NULL_VALUES + ) AS [6_rows]([rows]) FOR JSON PATH, + INCLUDE_NULL_VALUES, + WITHOUT_ARRAY_WRAPPER [] diff --git a/crates/query-engine/translation/tests/snapshots/tests__it_simple_object_relationship.snap b/crates/query-engine/translation/tests/snapshots/tests__it_simple_object_relationship.snap index e815e10e..5a3a1063 100644 --- a/crates/query-engine/translation/tests/snapshots/tests__it_simple_object_relationship.snap +++ b/crates/query-engine/translation/tests/snapshots/tests__it_simple_object_relationship.snap @@ -3,48 +3,34 @@ source: crates/query-engine/translation/tests/tests.rs expression: result --- SELECT - row_to_json("%5_universe") AS "universe" + ISNULL([6_rows].[rows], '[]') AS [rows] FROM ( SELECT - * + JSON_QUERY([1_RELATIONSHIP_Artist].[json], '$') AS [Artist] FROM - ( + [public].[Album] AS [0_Album] + OUTER APPLY ( SELECT - coalesce(json_agg(row_to_json("%6_rows")), '[]') AS "rows" + ISNULL([3_rows].[row_json], '[]') AS [rows] FROM ( SELECT - "%1_RELATIONSHIP_Artist"."Artist" AS "Artist" + [2_Artist].[Name] AS [Name] FROM - "public"."Album" AS "%0_Album" - LEFT OUTER JOIN LATERAL ( - SELECT - row_to_json("%1_RELATIONSHIP_Artist") AS "Artist" - FROM - ( - SELECT - * - FROM - ( - SELECT - coalesce(json_agg(row_to_json("%3_rows")), '[]') AS "rows" - FROM - ( - SELECT - "%2_Artist"."Name" AS "Name" - FROM - "public"."Artist" AS "%2_Artist" - WHERE - ("%0_Album"."ArtistId" = "%2_Artist"."ArtistId") - ) AS "%3_rows" - ) AS "%3_rows" - ) AS "%1_RELATIONSHIP_Artist" - ) AS "%1_RELATIONSHIP_Artist" ON ('true') - LIMIT - 5 - ) AS "%6_rows" - ) AS "%6_rows" - ) AS "%5_universe" + [public].[Artist] AS [2_Artist] + WHERE + ([0_Album].[ArtistId] = [2_Artist].[ArtistId]) FOR JSON PATH, + INCLUDE_NULL_VALUES + ) AS [3_rows]([row_json]) FOR JSON PATH, + INCLUDE_NULL_VALUES, + WITHOUT_ARRAY_WRAPPER + ) AS [1_RELATIONSHIP_Artist]([json]) + ORDER BY + [0_Album].[AlbumId] ASC OFFSET 0 ROWS FETCH NEXT 5 ROWS ONLY FOR JSON PATH, + INCLUDE_NULL_VALUES + ) AS [6_rows]([rows]) FOR JSON PATH, + INCLUDE_NULL_VALUES, + WITHOUT_ARRAY_WRAPPER [] diff --git a/crates/query-engine/translation/tests/snapshots/tests__nested_aggregates.snap b/crates/query-engine/translation/tests/snapshots/tests__nested_aggregates.snap index f9ef2f0e..289dd87a 100644 --- a/crates/query-engine/translation/tests/snapshots/tests__nested_aggregates.snap +++ b/crates/query-engine/translation/tests/snapshots/tests__nested_aggregates.snap @@ -3,62 +3,63 @@ source: crates/query-engine/translation/tests/tests.rs expression: result --- SELECT - row_to_json("%5_universe") AS "universe" + ISNULL([6_rows].[rows], '[]') AS [rows] FROM ( SELECT - * + [0_Artist].[Name] AS [Name], + JSON_QUERY([1_RELATIONSHIP_Albums].[json], '$') AS [Albums] FROM - ( + [public].[Artist] AS [0_Artist] + OUTER APPLY ( SELECT - coalesce(json_agg(row_to_json("%6_rows")), '[]') AS "rows" + JSON_QUERY(ISNULL([3_rows].[row_json], '[]'), '$.row_json') AS [rows], + JSON_QUERY( + JSON_VALUE([4_aggregates].[agg_json], '$.agg_json'), + '$' + ) AS [aggregates] FROM ( SELECT - "%0_Artist"."Name" AS "Name", - "%1_RELATIONSHIP_Albums"."Albums" AS "Albums" + * FROM - "public"."Artist" AS "%0_Artist" - LEFT OUTER JOIN LATERAL ( + ( SELECT - row_to_json("%1_RELATIONSHIP_Albums") AS "Albums" + [2_Album].[Title] AS [Title] FROM - ( - SELECT - * - FROM - ( - SELECT - coalesce(json_agg(row_to_json("%3_rows")), '[]') AS "rows" - FROM - ( - SELECT - "%2_Album"."Title" AS "Title" - FROM - "public"."Album" AS "%2_Album" - WHERE - ("%0_Artist"."ArtistId" = "%2_Album"."ArtistId") - ) AS "%3_rows" - ) AS "%3_rows" - CROSS JOIN ( - SELECT - coalesce(row_to_json("%4_aggregates"), '[]') AS "aggregates" - FROM - ( - SELECT - COUNT(*) AS "how_many_albums" - FROM - "public"."Album" AS "%2_Album" - WHERE - ("%0_Artist"."ArtistId" = "%2_Album"."ArtistId") - ) AS "%4_aggregates" - ) AS "%4_aggregates" - ) AS "%1_RELATIONSHIP_Albums" - ) AS "%1_RELATIONSHIP_Albums" ON ('true') - LIMIT - 5 OFFSET 1 - ) AS "%6_rows" - ) AS "%6_rows" - ) AS "%5_universe" + [public].[Album] AS [2_Album] + WHERE + ([0_Artist].[ArtistId] = [2_Album].[ArtistId]) FOR JSON PATH, + INCLUDE_NULL_VALUES + ) AS [1_RELATIONSHIP_Albums]([row_json]) FOR JSON PATH, + INCLUDE_NULL_VALUES, + WITHOUT_ARRAY_WRAPPER + ) AS [3_rows]([row_json]) + CROSS JOIN ( + SELECT + * + FROM + ( + SELECT + COUNT(*) AS [how_many_albums] + FROM + [public].[Album] AS [2_Album] + WHERE + ([0_Artist].[ArtistId] = [2_Album].[ArtistId]) FOR JSON PATH, + INCLUDE_NULL_VALUES, + WITHOUT_ARRAY_WRAPPER + ) AS [4_aggregates]([agg_json]) FOR JSON PATH, + INCLUDE_NULL_VALUES, + WITHOUT_ARRAY_WRAPPER + ) AS [4_aggregates]([agg_json]) FOR JSON PATH, + INCLUDE_NULL_VALUES, + WITHOUT_ARRAY_WRAPPER + ) AS [1_RELATIONSHIP_Albums]([json]) + ORDER BY + [0_Artist].[ArtistId] ASC OFFSET 1 ROWS FETCH NEXT 5 ROWS ONLY FOR JSON PATH, + INCLUDE_NULL_VALUES + ) AS [6_rows]([rows]) FOR JSON PATH, + INCLUDE_NULL_VALUES, + WITHOUT_ARRAY_WRAPPER []