@contember/engine-content-api 2.0.9 → 2.0.10

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contember/engine-content-api",
3
- "version": "2.0.9",
3
+ "version": "2.0.10",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/production/index.js",
6
6
  "typings": "./dist/types/index.d.ts",
@@ -26,21 +26,21 @@
26
26
  "generate": "gql-gen --config graphql.codegen.yml"
27
27
  },
28
28
  "dependencies": {
29
- "@contember/database": "2.0.9",
30
- "@contember/dic": "2.0.9",
31
- "@contember/graphql-utils": "2.0.9",
32
- "@contember/logger": "2.0.9",
33
- "@contember/schema": "2.0.9",
34
- "@contember/schema-definition": "2.0.9",
35
- "@contember/schema-utils": "2.0.9",
29
+ "@contember/database": "2.0.10",
30
+ "@contember/dic": "2.0.10",
31
+ "@contember/graphql-utils": "2.0.10",
32
+ "@contember/logger": "2.0.10",
33
+ "@contember/schema": "2.0.10",
34
+ "@contember/schema-definition": "2.0.10",
35
+ "@contember/schema-utils": "2.0.10",
36
36
  "fast-deep-equal": "^3.1.3"
37
37
  },
38
38
  "devDependencies": {
39
- "@contember/database-tester": "2.0.9",
40
- "@contember/schema-definition": "2.0.9",
39
+ "@contember/database-tester": "2.0.10",
40
+ "@contember/schema-definition": "2.0.10",
41
41
  "@types/node": "^20.16.11",
42
42
  "graphql": "^16.9.0",
43
- "pg": "^8.12.0"
43
+ "pg": "^8.20.0"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "graphql": ">= 14.6.0",
@@ -163,9 +163,7 @@ export class RelationFetcher {
163
163
 
164
164
  const primaryField = new FieldNode(targetEntity.primary, targetEntity.primary, {})
165
165
  const inverseJoiningColumn = joiningColumns.targetColumn.columnName
166
- const inverseIds = junctionValues
167
- .map(it => it[inverseJoiningColumn])
168
- .filter((it, index, arr) => arr.indexOf(it) === index)
166
+ const inverseIds = [...new Set(junctionValues.map(it => it[inverseJoiningColumn]))]
169
167
 
170
168
  const queryWithWhere = objectNode
171
169
  .withArgs({
@@ -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: [
@@ -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_id", "root_"."id" as "root_id" from "public"."author" as "root_"`,
245
+ response: { rows: [{ root_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
+ })
@@ -223,7 +223,7 @@ test('Posts with paginated comments (one has many)', async () => {
223
223
  where "root_"."deleted_at" is null
224
224
  and "root_"."post_id" in (?, ?)
225
225
  order by "root_"."id" asc)
226
- select "data".* from "data" where "data"."rowNumber_" <= ?`,
226
+ select "data".* from "data" where "data"."rowNumber_" <= ? order by "data"."rowNumber_" asc`,
227
227
  parameters: [testUuid(1), testUuid(2), 1],
228
228
  response: {
229
229
  rows: [
@@ -377,7 +377,7 @@ test('Posts with paginated comments without count (one has many)', async () => {
377
377
  where "root_"."deleted_at" is null
378
378
  and "root_"."post_id" in (?, ?)
379
379
  order by "root_"."id" asc)
380
- select "data".* from "data" where "data"."rowNumber_" <= ?`,
380
+ select "data".* from "data" where "data"."rowNumber_" <= ? order by "data"."rowNumber_" asc`,
381
381
  parameters: [testUuid(1), testUuid(2), 1],
382
382
  response: {
383
383
  rows: [
@@ -474,7 +474,7 @@ test('Posts with paginated comments (one has many)', async () => {
474
474
  where "root_"."deleted_at" is null
475
475
  and "root_"."post_id" in (?)
476
476
  order by "root_"."id" asc)
477
- select "data".* from "data" where "data"."rowNumber_" <= ?`,
477
+ select "data".* from "data" where "data"."rowNumber_" <= ? order by "data"."rowNumber_" asc`,
478
478
  parameters: [testUuid(1), 1],
479
479
  response: {
480
480
  rows: [
@@ -139,7 +139,7 @@ test('sorts posts by random on has many relation', async () => {
139
139
  inner join "rand_seed" on true
140
140
  where "junction_"."category_id" in (?, ?)
141
141
  order by random() asc)
142
- select "data".* from "data" where "data"."rownumber_" <= ?`,
142
+ select "data".* from "data" where "data"."rownumber_" <= ? order by "data"."rownumber_" asc`,
143
143
  parameters: [4555 / Math.pow(2, 31), testUuid(1), testUuid(2), 1],
144
144
  response: {
145
145
  rows: [