@contember/engine-content-api 2.0.9 → 2.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/development/src/mapper/ErrorUtils.cjs +7 -1
  2. package/dist/development/src/mapper/ErrorUtils.cjs.map +1 -1
  3. package/dist/development/src/mapper/ErrorUtils.js +7 -1
  4. package/dist/development/src/mapper/ErrorUtils.js.map +1 -1
  5. package/dist/development/src/mapper/Mapper.cjs +2 -1
  6. package/dist/development/src/mapper/Mapper.cjs.map +1 -1
  7. package/dist/development/src/mapper/Mapper.js +2 -1
  8. package/dist/development/src/mapper/Mapper.js.map +1 -1
  9. package/dist/development/src/mapper/select/Path.cjs +23 -3
  10. package/dist/development/src/mapper/select/Path.cjs.map +1 -1
  11. package/dist/development/src/mapper/select/Path.js +23 -3
  12. package/dist/development/src/mapper/select/Path.js.map +1 -1
  13. package/dist/development/src/mapper/select/RelationFetcher.cjs +1 -1
  14. package/dist/development/src/mapper/select/RelationFetcher.cjs.map +1 -1
  15. package/dist/development/src/mapper/select/RelationFetcher.js +1 -1
  16. package/dist/development/src/mapper/select/RelationFetcher.js.map +1 -1
  17. package/dist/development/src/mapper/select/SelectBuilder.cjs +5 -5
  18. package/dist/development/src/mapper/select/SelectBuilder.cjs.map +1 -1
  19. package/dist/development/src/mapper/select/SelectBuilder.js +5 -5
  20. package/dist/development/src/mapper/select/SelectBuilder.js.map +1 -1
  21. package/dist/development/src/resolvers/MutationResolver.cjs +1 -0
  22. package/dist/development/src/resolvers/MutationResolver.cjs.map +1 -1
  23. package/dist/development/src/resolvers/MutationResolver.js +1 -0
  24. package/dist/development/src/resolvers/MutationResolver.js.map +1 -1
  25. package/dist/production/src/mapper/ErrorUtils.cjs +7 -1
  26. package/dist/production/src/mapper/ErrorUtils.cjs.map +1 -1
  27. package/dist/production/src/mapper/ErrorUtils.js +7 -1
  28. package/dist/production/src/mapper/ErrorUtils.js.map +1 -1
  29. package/dist/production/src/mapper/Mapper.cjs +2 -1
  30. package/dist/production/src/mapper/Mapper.cjs.map +1 -1
  31. package/dist/production/src/mapper/Mapper.js +2 -1
  32. package/dist/production/src/mapper/Mapper.js.map +1 -1
  33. package/dist/production/src/mapper/select/Path.cjs +23 -3
  34. package/dist/production/src/mapper/select/Path.cjs.map +1 -1
  35. package/dist/production/src/mapper/select/Path.js +23 -3
  36. package/dist/production/src/mapper/select/Path.js.map +1 -1
  37. package/dist/production/src/mapper/select/RelationFetcher.cjs +1 -1
  38. package/dist/production/src/mapper/select/RelationFetcher.cjs.map +1 -1
  39. package/dist/production/src/mapper/select/RelationFetcher.js +1 -1
  40. package/dist/production/src/mapper/select/RelationFetcher.js.map +1 -1
  41. package/dist/production/src/mapper/select/SelectBuilder.cjs +5 -5
  42. package/dist/production/src/mapper/select/SelectBuilder.cjs.map +1 -1
  43. package/dist/production/src/mapper/select/SelectBuilder.js +5 -5
  44. package/dist/production/src/mapper/select/SelectBuilder.js.map +1 -1
  45. package/dist/production/src/resolvers/MutationResolver.cjs +1 -0
  46. package/dist/production/src/resolvers/MutationResolver.cjs.map +1 -1
  47. package/dist/production/src/resolvers/MutationResolver.js +1 -0
  48. package/dist/production/src/resolvers/MutationResolver.js.map +1 -1
  49. package/dist/tests/cases/unit/mutationSqlError.test.d.ts +2 -0
  50. package/dist/tests/cases/unit/mutationSqlError.test.d.ts.map +1 -0
  51. package/dist/tests/cases/unit/pathAlias.test.d.ts +2 -0
  52. package/dist/tests/cases/unit/pathAlias.test.d.ts.map +1 -0
  53. package/dist/tests/tsconfig.tsbuildinfo +1 -1
  54. package/dist/types/mapper/ErrorUtils.d.ts.map +1 -1
  55. package/dist/types/mapper/select/Path.d.ts +1 -0
  56. package/dist/types/mapper/select/Path.d.ts.map +1 -1
  57. package/dist/types/mapper/select/RelationFetcher.d.ts.map +1 -1
  58. package/dist/types/mapper/select/SelectBuilder.d.ts.map +1 -1
  59. package/dist/types/tsconfig.tsbuildinfo +1 -1
  60. package/package.json +11 -11
  61. package/src/mapper/ErrorUtils.ts +11 -1
  62. package/src/mapper/Mapper.ts +1 -1
  63. package/src/mapper/select/Path.ts +25 -5
  64. package/src/mapper/select/RelationFetcher.ts +1 -3
  65. package/src/mapper/select/SelectBuilder.ts +10 -5
  66. package/tests/cases/bugs/bug102.test.ts +4 -4
  67. package/tests/cases/integration/graphQlRequests/delete/deleteById.test.ts +7 -6
  68. package/tests/cases/integration/graphQlRequests/query/acl/differentRowAndFieldPredicate.test.ts +8 -8
  69. package/tests/cases/integration/graphQlRequests/query/acl/fieldRestrictedByLocale.test.ts +26 -24
  70. package/tests/cases/integration/graphQlRequests/query/acl/nestedPredicate.test.ts +11 -10
  71. package/tests/cases/integration/graphQlRequests/query/acl/predicateElimination.test.ts +7 -6
  72. package/tests/cases/integration/graphQlRequests/query/acl/relationAcl.test.ts +22 -19
  73. package/tests/cases/integration/graphQlRequests/query/acl/rowPredicateSubset.test.ts +12 -12
  74. package/tests/cases/integration/graphQlRequests/query/filter/backReferencedFilter.test.ts +5 -3
  75. package/tests/cases/integration/graphQlRequests/query/graphqlFeatures/alias.test.ts +6 -6
  76. package/tests/cases/integration/graphQlRequests/query/graphqlFeatures/fragments.test.ts +8 -8
  77. package/tests/cases/integration/graphQlRequests/query/misc/reducedHasMany.test.ts +10 -10
  78. package/tests/cases/integration/graphQlRequests/query/pagination/hasManyLimit.test.ts +53 -8
  79. package/tests/cases/integration/graphQlRequests/query/pagination/paginate.test.ts +13 -10
  80. package/tests/cases/integration/graphQlRequests/query/pagination/paginateAliased.test.ts +13 -10
  81. package/tests/cases/integration/graphQlRequests/query/relations/advanced.test.ts +34 -25
  82. package/tests/cases/integration/graphQlRequests/query/relations/manyHasManyInverse.test.ts +6 -6
  83. package/tests/cases/integration/graphQlRequests/query/relations/manyHasManyOwning.test.ts +6 -6
  84. package/tests/cases/integration/graphQlRequests/query/relations/manyHasOne.test.ts +21 -18
  85. package/tests/cases/integration/graphQlRequests/query/relations/oneHasMany.test.ts +15 -15
  86. package/tests/cases/integration/graphQlRequests/query/relations/oneHasOneInverse.test.ts +14 -12
  87. package/tests/cases/integration/graphQlRequests/query/relations/oneHasOneOwner.test.ts +14 -12
  88. package/tests/cases/integration/graphQlRequests/query/sorting/defaultOrdering.test.ts +4 -4
  89. package/tests/cases/integration/graphQlRequests/query/sorting/randomSort.test.ts +4 -4
  90. package/tests/cases/integration/graphQlRequests/query/sorting/sortedHasMany.test.ts +2 -2
  91. package/tests/cases/integration/graphQlRequests/query/view/view.test.ts +10 -10
  92. package/tests/cases/unit/mutationSqlError.test.ts +30 -0
  93. package/tests/cases/unit/pathAlias.test.ts +26 -0
@@ -43,11 +43,11 @@ test('fragments', async () => {
43
43
  sql: SQL`select
44
44
  "root_"."id" as "root_id",
45
45
  "root_"."name" as "root_name",
46
- "root_"."id" as "root_id"
46
+ "root_"."id" as "root_$key_id"
47
47
  from "public"."author" as "root_"`,
48
48
  parameters: [],
49
49
  response: {
50
- rows: [{ root_id: testUuid(1), root_name: 'John' }],
50
+ rows: [{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1), 'root_name': 'John' }],
51
51
  },
52
52
  },
53
53
  {
@@ -108,21 +108,21 @@ test('fragments merge', async () => {
108
108
  }`,
109
109
  executes: [
110
110
  {
111
- sql: `select "root_"."id" as "root_id", "root_"."id" as "root_id" from "public"."product" as "root_"`,
111
+ sql: `select "root_"."id" as "root_$key_id", "root_"."id" as "root_id" from "public"."product" as "root_"`,
112
112
  parameters: [],
113
- response: { rows: [{ root_id: testUuid(1) }] },
113
+ response: { rows: [{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1) }] },
114
114
  },
115
115
  {
116
- sql: `select "root_"."product_id" as "__grouping_key", "root_"."name" as "root_name", "root_"."image_id" as "root_image", "root_"."id" as "root_id" from "public"."product_locale" as "root_" where "root_"."product_id" in (?)`,
116
+ sql: `select "root_"."product_id" as "__grouping_key", "root_"."name" as "root_name", "root_"."image_id" as "root_$key_image", "root_"."id" as "root_id" from "public"."product_locale" as "root_" where "root_"."product_id" in (?)`,
117
117
  parameters: [testUuid(1)],
118
118
  response: {
119
- rows: [{ __grouping_key: testUuid(1), root_name: 'foo', root_id: testUuid(2), root_image: testUuid(3) }],
119
+ rows: [{ '__grouping_key': testUuid(1), 'root_name': 'foo', 'root_id': testUuid(2), 'root_$key_image': testUuid(3) }],
120
120
  },
121
121
  },
122
122
  {
123
- sql: `select "root_"."id" as "root_id", "root_"."url" as "root_url", "root_"."id" as "root_id" from "public"."image" as "root_" where "root_"."id" in (?)`,
123
+ sql: `select "root_"."id" as "root_$index_id", "root_"."url" as "root_url", "root_"."id" as "root_id" from "public"."image" as "root_" where "root_"."id" in (?)`,
124
124
  parameters: [testUuid(3)],
125
- response: { rows: [{ root_id: testUuid(3), root_url: 'abcd' }] },
125
+ response: { rows: [{ 'root_id': testUuid(3), 'root_$index_id': testUuid(3), 'root_url': 'abcd' }] },
126
126
  },
127
127
  ],
128
128
  return: {
@@ -34,24 +34,24 @@ test('reduced has many', async () => {
34
34
  {
35
35
  sql: SQL`select
36
36
  "root_"."id" as "root_id",
37
- "root_"."id" as "root_id"
37
+ "root_"."id" as "root_$key_id"
38
38
  from "public"."post" as "root_"`,
39
39
  parameters: [],
40
40
  response: {
41
- rows: [{ root_id: testUuid(1) }, { root_id: testUuid(2) }],
41
+ rows: [{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1) }, { 'root_id': testUuid(2), 'root_$key_id': testUuid(2) }],
42
42
  },
43
43
  },
44
44
  {
45
45
  sql: SQL`select
46
- "root_"."post_id" as "root_post",
46
+ "root_"."post_id" as "root_$index_post",
47
47
  "root_"."id" as "root_id"
48
48
  from "public"."post_locale" as "root_"
49
49
  where "root_"."locale" = ? and "root_"."post_id" in (?, ?)`,
50
50
  parameters: ['cs', testUuid(1), testUuid(2)],
51
51
  response: {
52
52
  rows: [
53
- { root_post: testUuid(1), root_id: testUuid(11) },
54
- { root_post: testUuid(2), root_id: testUuid(12) },
53
+ { 'root_$index_post': testUuid(1), 'root_id': testUuid(11) },
54
+ { 'root_$index_post': testUuid(2), 'root_id': testUuid(12) },
55
55
  ],
56
56
  },
57
57
  },
@@ -103,24 +103,24 @@ test('universal reduced has many', async () => {
103
103
  {
104
104
  sql: SQL`select
105
105
  "root_"."id" as "root_id",
106
- "root_"."id" as "root_id"
106
+ "root_"."id" as "root_$key_id"
107
107
  from "public"."post" as "root_"`,
108
108
  parameters: [],
109
109
  response: {
110
- rows: [{ root_id: testUuid(1) }, { root_id: testUuid(2) }],
110
+ rows: [{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1) }, { 'root_id': testUuid(2), 'root_$key_id': testUuid(2) }],
111
111
  },
112
112
  },
113
113
  {
114
114
  sql: SQL`select
115
- "root_"."post_id" as "root_post",
115
+ "root_"."post_id" as "root_$index_post",
116
116
  "root_"."id" as "root_id"
117
117
  from "public"."post_locale" as "root_"
118
118
  where "root_"."locale" = ? and "root_"."post_id" in (?, ?)`,
119
119
  parameters: ['cs', testUuid(1), testUuid(2)],
120
120
  response: {
121
121
  rows: [
122
- { root_post: testUuid(1), root_id: testUuid(11) },
123
- { root_post: testUuid(2), root_id: testUuid(12) },
122
+ { 'root_$index_post': testUuid(1), 'root_id': testUuid(11) },
123
+ { 'root_$index_post': testUuid(2), 'root_id': testUuid(12) },
124
124
  ],
125
125
  },
126
126
  },
@@ -33,13 +33,13 @@ test('many has many with where, limit and orderBy', async () => {
33
33
  sql: SQL`select
34
34
  "root_"."id" as "root_id",
35
35
  "root_"."title" as "root_title",
36
- "root_"."id" as "root_id"
36
+ "root_"."id" as "root_$key_id"
37
37
  from "public"."category" as "root_"`,
38
38
  parameters: [],
39
39
  response: {
40
40
  rows: [
41
- { root_id: testUuid(1), root_title: 'Hello' },
42
- { root_id: testUuid(2), root_title: 'World' },
41
+ { 'root_id': testUuid(1), 'root_$key_id': testUuid(1), 'root_title': 'Hello' },
42
+ { 'root_id': testUuid(2), 'root_$key_id': testUuid(2), 'root_title': 'World' },
43
43
  ],
44
44
  },
45
45
  },
@@ -58,7 +58,8 @@ test('many has many with where, limit and orderBy', async () => {
58
58
  "data".*
59
59
  from "data"
60
60
  where
61
- "data"."rowNumber_" > ? and "data"."rowNumber_" <= ?`,
61
+ "data"."rowNumber_" > ? and "data"."rowNumber_" <= ?
62
+ order by "data"."rowNumber_" asc`,
62
63
  parameters: [testUuid(1), testUuid(2), 'cs', 1, 3],
63
64
  response: {
64
65
  rows: [
@@ -155,13 +156,13 @@ test('one has many with where, limit and orderBy', async () => {
155
156
  sql: SQL`select
156
157
  "root_"."id" as "root_id",
157
158
  "root_"."name" as "root_name",
158
- "root_"."id" as "root_id"
159
+ "root_"."id" as "root_$key_id"
159
160
  from "public"."author" as "root_"`,
160
161
  parameters: [],
161
162
  response: {
162
163
  rows: [
163
- { root_id: testUuid(1), root_name: 'John' },
164
- { root_id: testUuid(2), root_name: 'Jack' },
164
+ { 'root_id': testUuid(1), 'root_$key_id': testUuid(1), 'root_name': 'John' },
165
+ { 'root_id': testUuid(2), 'root_$key_id': testUuid(2), 'root_name': 'Jack' },
165
166
  ],
166
167
  },
167
168
  },
@@ -179,7 +180,8 @@ test('one has many with where, limit and orderBy', async () => {
179
180
  order by "root_"."title" asc, "root_"."id" asc)
180
181
  select "data".*
181
182
  from "data"
182
- where "data"."rowNumber_" > ? and "data"."rowNumber_" <= ?`,
183
+ where "data"."rowNumber_" > ? and "data"."rowNumber_" <= ?
184
+ order by "data"."rowNumber_" asc`,
183
185
  parameters: ['cs', testUuid(1), testUuid(2), 1, 3],
184
186
  response: {
185
187
  rows: [
@@ -223,3 +225,46 @@ test('one has many with where, limit and orderBy', async () => {
223
225
  })
224
226
  })
225
227
 
228
+ test('one has many with nulls first in a limited page', async () => {
229
+ await execute({
230
+ schema: new SchemaBuilder()
231
+ .entity('Author', entity => entity.oneHasMany('posts', relation => relation.target('Post', entity => entity.column('title')).ownedBy('author')))
232
+ .buildSchema(),
233
+ query: GQL`
234
+ query {
235
+ listAuthor {
236
+ posts(orderBy: [{title: ascNullsFirst}], limit: 1) {
237
+ id
238
+ title
239
+ }
240
+ }
241
+ }`,
242
+ executes: [
243
+ {
244
+ sql: SQL`select "root_"."id" as "root_$key_id", "root_"."id" as "root_id" from "public"."author" as "root_"`,
245
+ response: { rows: [{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1) }] },
246
+ },
247
+ {
248
+ sql: SQL`with "data" as
249
+ (select "root_"."author_id" as "__grouping_key",
250
+ "root_"."id" as "root_id",
251
+ "root_"."title" as "root_title",
252
+ row_number() over(partition by "root_"."author_id"
253
+ order by "root_"."title" asc nulls first, "root_"."id" asc) as "rowNumber_"
254
+ from "public"."post" as "root_"
255
+ where "root_"."author_id" in (?)
256
+ order by "root_"."title" asc nulls first, "root_"."id" asc)
257
+ select "data".* from "data"
258
+ where "data"."rowNumber_" <= ?
259
+ order by "data"."rowNumber_" asc`,
260
+ parameters: [testUuid(1), 1],
261
+ response: { rows: [{ __grouping_key: testUuid(1), root_id: testUuid(2), root_title: null }] },
262
+ },
263
+ ],
264
+ return: {
265
+ data: {
266
+ listAuthor: [{ posts: [{ id: testUuid(2), title: null }] }],
267
+ },
268
+ },
269
+ })
270
+ })
@@ -42,21 +42,23 @@ where "root_author"."name" = ?`,
42
42
  response: { rows: [{ row_count: 10 }] },
43
43
  },
44
44
  {
45
- sql: SQL`select "root_"."id" as "root_id", "root_"."title" as "root_title", "root_"."author_id" as "root_author"
45
+ sql: SQL`select "root_"."id" as "root_id", "root_"."title" as "root_title", "root_"."author_id" as "root_$key_author"
46
46
  from "public"."post" as "root_"
47
47
  left join "public"."author" as "root_author" on "root_"."author_id" = "root_author"."id"
48
48
  where "root_author"."name" = ? order by "root_"."id" asc limit 2 offset 1`,
49
49
  response: {
50
50
  rows: [
51
51
  {
52
- root_id: testUuid(1),
53
- root_title: 'Foo',
54
- root_author: testUuid(2),
52
+ 'root_id': testUuid(1),
53
+ 'root_title': 'Foo',
54
+ 'root_author': testUuid(2),
55
+ 'root_$key_author': testUuid(2),
55
56
  },
56
57
  {
57
- root_id: testUuid(3),
58
- root_title: 'Bar',
59
- root_author: testUuid(2),
58
+ 'root_id': testUuid(3),
59
+ 'root_title': 'Bar',
60
+ 'root_author': testUuid(2),
61
+ 'root_$key_author': testUuid(2),
60
62
  },
61
63
  ],
62
64
  },
@@ -64,7 +66,7 @@ where "root_author"."name" = ? order by "root_"."id" asc limit 2 offset 1`,
64
66
  {
65
67
  sql: SQL`
66
68
  select
67
- "root_"."id" as "root_id",
69
+ "root_"."id" as "root_$index_id",
68
70
  "root_"."name" as "root_name",
69
71
  "root_"."id" as "root_id"
70
72
  from "public"."author" as "root_"
@@ -74,8 +76,9 @@ where "root_author"."name" = ? order by "root_"."id" asc limit 2 offset 1`,
74
76
  response: {
75
77
  rows: [
76
78
  {
77
- root_id: testUuid(2),
78
- root_name: 'jack',
79
+ 'root_id': testUuid(2),
80
+ 'root_$index_id': testUuid(2),
81
+ 'root_name': 'jack',
79
82
  },
80
83
  ],
81
84
  },
@@ -42,21 +42,23 @@ where "root_author"."name" = ?`,
42
42
  response: { rows: [{ row_count: 10 }] },
43
43
  },
44
44
  {
45
- sql: SQL`select "root_"."id" as "root_id", "root_"."title" as "root_title", "root_"."author_id" as "root_author"
45
+ sql: SQL`select "root_"."id" as "root_id", "root_"."title" as "root_title", "root_"."author_id" as "root_$key_author"
46
46
  from "public"."post" as "root_"
47
47
  left join "public"."author" as "root_author" on "root_"."author_id" = "root_author"."id"
48
48
  where "root_author"."name" = ? order by "root_"."id" asc limit 2 offset 1`,
49
49
  response: {
50
50
  rows: [
51
51
  {
52
- root_id: testUuid(1),
53
- root_title: 'Foo',
54
- root_author: testUuid(2),
52
+ 'root_id': testUuid(1),
53
+ 'root_title': 'Foo',
54
+ 'root_author': testUuid(2),
55
+ 'root_$key_author': testUuid(2),
55
56
  },
56
57
  {
57
- root_id: testUuid(3),
58
- root_title: 'Bar',
59
- root_author: testUuid(2),
58
+ 'root_id': testUuid(3),
59
+ 'root_title': 'Bar',
60
+ 'root_author': testUuid(2),
61
+ 'root_$key_author': testUuid(2),
60
62
  },
61
63
  ],
62
64
  },
@@ -64,7 +66,7 @@ where "root_author"."name" = ? order by "root_"."id" asc limit 2 offset 1`,
64
66
  {
65
67
  sql: SQL`
66
68
  select
67
- "root_"."id" as "root_id",
69
+ "root_"."id" as "root_$index_id",
68
70
  "root_"."name" as "root_name",
69
71
  "root_"."id" as "root_id"
70
72
  from "public"."author" as "root_"
@@ -74,8 +76,9 @@ where "root_author"."name" = ? order by "root_"."id" asc limit 2 offset 1`,
74
76
  response: {
75
77
  rows: [
76
78
  {
77
- root_id: testUuid(2),
78
- root_name: 'jack',
79
+ 'root_id': testUuid(2),
80
+ 'root_$index_id': testUuid(2),
81
+ 'root_name': 'jack',
79
82
  },
80
83
  ],
81
84
  },
@@ -39,15 +39,17 @@ test('Posts with categories and its cz locale (many has many owning + one has ma
39
39
  {
40
40
  sql: SQL`select
41
41
  "root_"."id" as "root_id",
42
- "root_"."id" as "root_id"
42
+ "root_"."id" as "root_$key_id"
43
43
  from "public"."post" as "root_"`,
44
44
  response: {
45
45
  rows: [
46
46
  {
47
- root_id: testUuid(1),
47
+ 'root_id': testUuid(1),
48
+ 'root_$key_id': testUuid(1),
48
49
  },
49
50
  {
50
- root_id: testUuid(2),
51
+ 'root_id': testUuid(2),
52
+ 'root_$key_id': testUuid(2),
51
53
  },
52
54
  ],
53
55
  },
@@ -83,7 +85,7 @@ test('Posts with categories and its cz locale (many has many owning + one has ma
83
85
  {
84
86
  sql: SQL`select
85
87
  "root_"."visible" as "root_visible",
86
- "root_"."id" as "root_id",
88
+ "root_"."id" as "root_$key_id",
87
89
  "root_"."id" as "root_id"
88
90
  from "public"."category" as "root_"
89
91
  where "root_"."id" in (?, ?, ?)`,
@@ -91,16 +93,19 @@ test('Posts with categories and its cz locale (many has many owning + one has ma
91
93
  response: {
92
94
  rows: [
93
95
  {
94
- root_id: testUuid(3),
95
- root_visible: true,
96
+ 'root_id': testUuid(3),
97
+ 'root_$key_id': testUuid(3),
98
+ 'root_visible': true,
96
99
  },
97
100
  {
98
- root_id: testUuid(4),
99
- root_visible: true,
101
+ 'root_id': testUuid(4),
102
+ 'root_$key_id': testUuid(4),
103
+ 'root_visible': true,
100
104
  },
101
105
  {
102
- root_id: testUuid(5),
103
- root_visible: true,
106
+ 'root_id': testUuid(5),
107
+ 'root_$key_id': testUuid(5),
108
+ 'root_visible': true,
104
109
  },
105
110
  ],
106
111
  },
@@ -222,15 +227,17 @@ test('Categories with posts and author (many has many inverse + many has one)',
222
227
  {
223
228
  sql: SQL`select
224
229
  "root_"."id" as "root_id",
225
- "root_"."id" as "root_id"
230
+ "root_"."id" as "root_$key_id"
226
231
  from "public"."category" as "root_"`,
227
232
  response: {
228
233
  rows: [
229
234
  {
230
- root_id: testUuid(1),
235
+ 'root_id': testUuid(1),
236
+ 'root_$key_id': testUuid(1),
231
237
  },
232
238
  {
233
- root_id: testUuid(2),
239
+ 'root_id': testUuid(2),
240
+ 'root_$key_id': testUuid(2),
234
241
  },
235
242
  ],
236
243
  },
@@ -265,7 +272,7 @@ test('Categories with posts and author (many has many inverse + many has one)',
265
272
  },
266
273
  {
267
274
  sql: SQL`select
268
- "root_"."author_id" as "root_author",
275
+ "root_"."author_id" as "root_$key_author",
269
276
  "root_"."id" as "root_id"
270
277
  from "public"."post" as "root_"
271
278
  where "root_"."id" in (?, ?, ?)
@@ -274,23 +281,23 @@ test('Categories with posts and author (many has many inverse + many has one)',
274
281
  response: {
275
282
  rows: [
276
283
  {
277
- root_id: testUuid(3),
278
- root_author: testUuid(6),
284
+ 'root_id': testUuid(3),
285
+ 'root_$key_author': testUuid(6),
279
286
  },
280
287
  {
281
- root_id: testUuid(4),
282
- root_author: testUuid(7),
288
+ 'root_id': testUuid(4),
289
+ 'root_$key_author': testUuid(7),
283
290
  },
284
291
  {
285
- root_id: testUuid(5),
286
- root_author: testUuid(7),
292
+ 'root_id': testUuid(5),
293
+ 'root_$key_author': testUuid(7),
287
294
  },
288
295
  ],
289
296
  },
290
297
  },
291
298
  {
292
299
  sql: SQL`select
293
- "root_"."id" as "root_id",
300
+ "root_"."id" as "root_$index_id",
294
301
  "root_"."name" as "root_name",
295
302
  "root_"."id" as "root_id"
296
303
  from "public"."author" as "root_"
@@ -300,12 +307,14 @@ test('Categories with posts and author (many has many inverse + many has one)',
300
307
  response: {
301
308
  rows: [
302
309
  {
303
- root_id: testUuid(6),
304
- root_name: 'John',
310
+ 'root_id': testUuid(6),
311
+ 'root_$index_id': testUuid(6),
312
+ 'root_name': 'John',
305
313
  },
306
314
  {
307
- root_id: testUuid(7),
308
- root_name: 'Jack',
315
+ 'root_id': testUuid(7),
316
+ 'root_$index_id': testUuid(7),
317
+ 'root_name': 'Jack',
309
318
  },
310
319
  ],
311
320
  },
@@ -32,10 +32,10 @@ test('Tags with paginated posts (many has many inverse)', async () => {
32
32
  executes: [
33
33
  {
34
34
  sql: SQL`select "root_"."id" as "root_id",
35
- "root_"."id" as "root_id"
35
+ "root_"."id" as "root_$key_id"
36
36
  from "public"."tag" as "root_"`,
37
37
  response: {
38
- rows: [{ root_id: testUuid(1) }, { root_id: testUuid(2) }],
38
+ rows: [{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1) }, { 'root_id': testUuid(2), 'root_$key_id': testUuid(2) }],
39
39
  },
40
40
  },
41
41
  {
@@ -139,10 +139,10 @@ test('empty many-has-many inverse relation', async () => {
139
139
  executes: [
140
140
  {
141
141
  sql: SQL`select "root_"."id" as "root_id",
142
- "root_"."id" as "root_id"
142
+ "root_"."id" as "root_$key_id"
143
143
  from "public"."tag" as "root_"`,
144
144
  response: {
145
- rows: [{ root_id: testUuid(1) }, { root_id: testUuid(2) }],
145
+ rows: [{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1) }, { 'root_id': testUuid(2), 'root_$key_id': testUuid(2) }],
146
146
  },
147
147
  },
148
148
  {
@@ -190,10 +190,10 @@ test('Posts with filtered tags', async () => {
190
190
  executes: [
191
191
  {
192
192
  sql: SQL`select "root_"."id" as "root_id",
193
- "root_"."id" as "root_id"
193
+ "root_"."id" as "root_$key_id"
194
194
  from "public"."post" as "root_"`,
195
195
  response: {
196
- rows: [{ root_id: testUuid(1) }, { root_id: testUuid(2) }],
196
+ rows: [{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1) }, { 'root_id': testUuid(2), 'root_$key_id': testUuid(2) }],
197
197
  },
198
198
  },
199
199
  {
@@ -24,10 +24,10 @@ test('Posts with filtered tags', async () => {
24
24
  executes: [
25
25
  {
26
26
  sql: SQL`select "root_"."id" as "root_id",
27
- "root_"."id" as "root_id"
27
+ "root_"."id" as "root_$key_id"
28
28
  from "public"."post" as "root_"`,
29
29
  response: {
30
- rows: [{ root_id: testUuid(1) }, { root_id: testUuid(2) }],
30
+ rows: [{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1) }, { 'root_id': testUuid(2), 'root_$key_id': testUuid(2) }],
31
31
  },
32
32
  },
33
33
  {
@@ -107,10 +107,10 @@ test('Posts with paginated tags (many has many owning)', async () => {
107
107
  executes: [
108
108
  {
109
109
  sql: SQL`select "root_"."id" as "root_id",
110
- "root_"."id" as "root_id"
110
+ "root_"."id" as "root_$key_id"
111
111
  from "public"."post" as "root_"`,
112
112
  response: {
113
- rows: [{ root_id: testUuid(1) }, { root_id: testUuid(2) }],
113
+ rows: [{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1) }, { 'root_id': testUuid(2), 'root_$key_id': testUuid(2) }],
114
114
  },
115
115
  },
116
116
  {
@@ -214,10 +214,10 @@ test.only('large number of posts - use array', async () => {
214
214
  executes: [
215
215
  {
216
216
  sql: SQL`select "root_"."id" as "root_id",
217
- "root_"."id" as "root_id"
217
+ "root_"."id" as "root_$key_id"
218
218
  from "public"."post" as "root_"`,
219
219
  response: {
220
- rows: ids.map(id => ({ root_id: id })),
220
+ rows: ids.map(id => ({ 'root_id': id, 'root_$key_id': id })),
221
221
  },
222
222
  },
223
223
  {
@@ -26,18 +26,18 @@ test('Post with author query (many has one)', async () => {
26
26
  sql: SQL`
27
27
  select
28
28
  "root_"."id" as "root_id",
29
- "root_"."author_id" as "root_author"
29
+ "root_"."author_id" as "root_$key_author"
30
30
  from "public"."post" as "root_"
31
31
  `,
32
32
  response: {
33
33
  rows: [
34
34
  {
35
- root_id: testUuid(1),
36
- root_author: testUuid(2),
35
+ 'root_id': testUuid(1),
36
+ 'root_$key_author': testUuid(2),
37
37
  },
38
38
  {
39
- root_id: testUuid(3),
40
- root_author: testUuid(4),
39
+ 'root_id': testUuid(3),
40
+ 'root_$key_author': testUuid(4),
41
41
  },
42
42
  ],
43
43
  },
@@ -45,7 +45,7 @@ test('Post with author query (many has one)', async () => {
45
45
  {
46
46
  sql: SQL`
47
47
  select
48
- "root_"."id" as "root_id",
48
+ "root_"."id" as "root_$index_id",
49
49
  "root_"."id" as "root_id",
50
50
  "root_"."name" as "root_name"
51
51
  from "public"."author" as "root_"
@@ -55,12 +55,14 @@ test('Post with author query (many has one)', async () => {
55
55
  response: {
56
56
  rows: [
57
57
  {
58
- root_id: testUuid(2),
59
- root_name: 'John',
58
+ 'root_id': testUuid(2),
59
+ 'root_$index_id': testUuid(2),
60
+ 'root_name': 'John',
60
61
  },
61
62
  {
62
- root_id: testUuid(4),
63
- root_name: 'Jack',
63
+ 'root_id': testUuid(4),
64
+ 'root_$index_id': testUuid(4),
65
+ 'root_name': 'Jack',
64
66
  },
65
67
  ],
66
68
  },
@@ -110,7 +112,7 @@ test('Post with author query with no result', async () => {
110
112
  sql: SQL`
111
113
  select
112
114
  "root_"."id" as "root_id",
113
- "root_"."author_id" as "root_author"
115
+ "root_"."author_id" as "root_$key_author"
114
116
  from "public"."post" as "root_"
115
117
  `,
116
118
  response: {
@@ -145,24 +147,24 @@ test('Post with author filtered by name (where many has one)', async () => {
145
147
  {
146
148
  sql: SQL`select
147
149
  "root_"."id" as "root_id",
148
- "root_"."author_id" as "root_author"
150
+ "root_"."author_id" as "root_$key_author"
149
151
  from "public"."post" as "root_"`,
150
152
  response: {
151
153
  rows: [
152
154
  {
153
- root_id: testUuid(1),
154
- root_author: testUuid(2),
155
+ 'root_id': testUuid(1),
156
+ 'root_$key_author': testUuid(2),
155
157
  },
156
158
  {
157
- root_id: testUuid(3),
158
- root_author: testUuid(4),
159
+ 'root_id': testUuid(3),
160
+ 'root_$key_author': testUuid(4),
159
161
  },
160
162
  ],
161
163
  },
162
164
  },
163
165
  {
164
166
  sql: SQL`select
165
- "root_"."id" as "root_id",
167
+ "root_"."id" as "root_$index_id",
166
168
  "root_"."id" as "root_id"
167
169
  from "public"."author" as "root_"
168
170
  where "root_"."id" in (?, ?) and "root_"."name" = ?`,
@@ -170,7 +172,8 @@ test('Post with author filtered by name (where many has one)', async () => {
170
172
  response: {
171
173
  rows: [
172
174
  {
173
- root_id: testUuid(2),
175
+ 'root_id': testUuid(2),
176
+ 'root_$index_id': testUuid(2),
174
177
  },
175
178
  ],
176
179
  },