@contember/engine-content-api 2.0.10 → 2.0.12
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/dist/development/src/mapper/ErrorUtils.cjs +7 -1
- package/dist/development/src/mapper/ErrorUtils.cjs.map +1 -1
- package/dist/development/src/mapper/ErrorUtils.js +7 -1
- package/dist/development/src/mapper/ErrorUtils.js.map +1 -1
- package/dist/development/src/mapper/Mapper.cjs +2 -1
- package/dist/development/src/mapper/Mapper.cjs.map +1 -1
- package/dist/development/src/mapper/Mapper.js +2 -1
- package/dist/development/src/mapper/Mapper.js.map +1 -1
- package/dist/development/src/mapper/select/Path.cjs +23 -3
- package/dist/development/src/mapper/select/Path.cjs.map +1 -1
- package/dist/development/src/mapper/select/Path.js +23 -3
- package/dist/development/src/mapper/select/Path.js.map +1 -1
- package/dist/development/src/mapper/select/SelectBuilder.cjs +5 -5
- package/dist/development/src/mapper/select/SelectBuilder.cjs.map +1 -1
- package/dist/development/src/mapper/select/SelectBuilder.js +5 -5
- package/dist/development/src/mapper/select/SelectBuilder.js.map +1 -1
- package/dist/development/src/resolvers/MutationResolver.cjs +1 -0
- package/dist/development/src/resolvers/MutationResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/MutationResolver.js +1 -0
- package/dist/development/src/resolvers/MutationResolver.js.map +1 -1
- package/dist/production/src/mapper/ErrorUtils.cjs +7 -1
- package/dist/production/src/mapper/ErrorUtils.cjs.map +1 -1
- package/dist/production/src/mapper/ErrorUtils.js +7 -1
- package/dist/production/src/mapper/ErrorUtils.js.map +1 -1
- package/dist/production/src/mapper/Mapper.cjs +2 -1
- package/dist/production/src/mapper/Mapper.cjs.map +1 -1
- package/dist/production/src/mapper/Mapper.js +2 -1
- package/dist/production/src/mapper/Mapper.js.map +1 -1
- package/dist/production/src/mapper/select/Path.cjs +23 -3
- package/dist/production/src/mapper/select/Path.cjs.map +1 -1
- package/dist/production/src/mapper/select/Path.js +23 -3
- package/dist/production/src/mapper/select/Path.js.map +1 -1
- package/dist/production/src/mapper/select/SelectBuilder.cjs +5 -5
- package/dist/production/src/mapper/select/SelectBuilder.cjs.map +1 -1
- package/dist/production/src/mapper/select/SelectBuilder.js +5 -5
- package/dist/production/src/mapper/select/SelectBuilder.js.map +1 -1
- package/dist/production/src/resolvers/MutationResolver.cjs +1 -0
- package/dist/production/src/resolvers/MutationResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/MutationResolver.js +1 -0
- package/dist/production/src/resolvers/MutationResolver.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/query/acl/internalColumnAliases.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/internalColumnAliases.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/mutationSqlError.test.d.ts +2 -0
- package/dist/tests/cases/unit/mutationSqlError.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/pathAlias.test.d.ts +2 -0
- package/dist/tests/cases/unit/pathAlias.test.d.ts.map +1 -0
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/mapper/ErrorUtils.d.ts.map +1 -1
- package/dist/types/mapper/select/Path.d.ts +1 -0
- package/dist/types/mapper/select/Path.d.ts.map +1 -1
- package/dist/types/mapper/select/SelectBuilder.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/mapper/ErrorUtils.ts +11 -1
- package/src/mapper/Mapper.ts +1 -1
- package/src/mapper/select/Path.ts +25 -5
- package/src/mapper/select/SelectBuilder.ts +10 -5
- package/tests/cases/bugs/bug102.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/delete/deleteById.test.ts +7 -6
- package/tests/cases/integration/graphQlRequests/query/acl/differentRowAndFieldPredicate.test.ts +8 -8
- package/tests/cases/integration/graphQlRequests/query/acl/fieldRestrictedByLocale.test.ts +26 -24
- package/tests/cases/integration/graphQlRequests/query/acl/internalColumnAliases.test.ts +278 -0
- package/tests/cases/integration/graphQlRequests/query/acl/nestedPredicate.test.ts +11 -10
- package/tests/cases/integration/graphQlRequests/query/acl/predicateElimination.test.ts +7 -6
- package/tests/cases/integration/graphQlRequests/query/acl/relationAcl.test.ts +22 -19
- package/tests/cases/integration/graphQlRequests/query/acl/rowPredicateSubset.test.ts +12 -12
- package/tests/cases/integration/graphQlRequests/query/filter/backReferencedFilter.test.ts +5 -3
- package/tests/cases/integration/graphQlRequests/query/graphqlFeatures/alias.test.ts +6 -6
- package/tests/cases/integration/graphQlRequests/query/graphqlFeatures/fragments.test.ts +8 -8
- package/tests/cases/integration/graphQlRequests/query/misc/reducedHasMany.test.ts +10 -10
- package/tests/cases/integration/graphQlRequests/query/pagination/hasManyLimit.test.ts +8 -8
- package/tests/cases/integration/graphQlRequests/query/pagination/paginate.test.ts +13 -10
- package/tests/cases/integration/graphQlRequests/query/pagination/paginateAliased.test.ts +13 -10
- package/tests/cases/integration/graphQlRequests/query/relations/advanced.test.ts +34 -25
- package/tests/cases/integration/graphQlRequests/query/relations/manyHasManyInverse.test.ts +6 -6
- package/tests/cases/integration/graphQlRequests/query/relations/manyHasManyOwning.test.ts +6 -6
- package/tests/cases/integration/graphQlRequests/query/relations/manyHasOne.test.ts +21 -18
- package/tests/cases/integration/graphQlRequests/query/relations/oneHasMany.test.ts +12 -12
- package/tests/cases/integration/graphQlRequests/query/relations/oneHasOneInverse.test.ts +14 -12
- package/tests/cases/integration/graphQlRequests/query/relations/oneHasOneOwner.test.ts +14 -12
- package/tests/cases/integration/graphQlRequests/query/sorting/defaultOrdering.test.ts +4 -4
- package/tests/cases/integration/graphQlRequests/query/sorting/randomSort.test.ts +3 -3
- package/tests/cases/integration/graphQlRequests/query/sorting/sortedHasMany.test.ts +2 -2
- package/tests/cases/integration/graphQlRequests/query/view/view.test.ts +10 -10
- package/tests/cases/unit/mutationSqlError.test.ts +30 -0
- package/tests/cases/unit/pathAlias.test.ts +26 -0
|
@@ -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 "
|
|
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 "
|
|
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 "
|
|
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 "
|
|
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 "
|
|
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 "
|
|
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 "
|
|
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
|
-
|
|
35
|
+
'root_id': testUuid(1),
|
|
36
|
+
'root_$key_author': testUuid(2),
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
|
-
root_id: testUuid(3),
|
|
40
|
-
|
|
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 "
|
|
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
|
-
|
|
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
|
-
|
|
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 "
|
|
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 "
|
|
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
|
-
|
|
155
|
+
'root_id': testUuid(1),
|
|
156
|
+
'root_$key_author': testUuid(2),
|
|
155
157
|
},
|
|
156
158
|
{
|
|
157
|
-
root_id: testUuid(3),
|
|
158
|
-
|
|
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 "
|
|
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
|
},
|
|
@@ -31,9 +31,9 @@ test('Posts with locales query (one has many)', async () => {
|
|
|
31
31
|
{
|
|
32
32
|
sql: SQL`select
|
|
33
33
|
"root_"."id" as "root_id",
|
|
34
|
-
"root_"."id" as "
|
|
34
|
+
"root_"."id" as "root_$key_id"
|
|
35
35
|
from "public"."post" as "root_"`,
|
|
36
|
-
response: { rows: [{ root_id: testUuid(1) }, { root_id: testUuid(2) }] },
|
|
36
|
+
response: { rows: [{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1) }, { 'root_id': testUuid(2), 'root_$key_id': testUuid(2) }] },
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
sql: SQL`select
|
|
@@ -113,10 +113,10 @@ test('Posts with locales query with where (one has many)', async () => {
|
|
|
113
113
|
{
|
|
114
114
|
sql: SQL`select
|
|
115
115
|
"root_"."id" as "root_id",
|
|
116
|
-
"root_"."id" as "
|
|
116
|
+
"root_"."id" as "root_$key_id"
|
|
117
117
|
from "public"."post" as "root_"`,
|
|
118
118
|
response: {
|
|
119
|
-
rows: [{ root_id: testUuid(1) }, { root_id: testUuid(2) }],
|
|
119
|
+
rows: [{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1) }, { 'root_id': testUuid(2), 'root_$key_id': testUuid(2) }],
|
|
120
120
|
},
|
|
121
121
|
},
|
|
122
122
|
{
|
|
@@ -192,10 +192,10 @@ test('Posts with paginated comments (one has many)', async () => {
|
|
|
192
192
|
{
|
|
193
193
|
sql: SQL`select
|
|
194
194
|
"root_"."id" as "root_id",
|
|
195
|
-
"root_"."id" as "
|
|
195
|
+
"root_"."id" as "root_$key_id"
|
|
196
196
|
from "public"."post" as "root_"`,
|
|
197
197
|
response: {
|
|
198
|
-
rows: [{ root_id: testUuid(1) }, { root_id: testUuid(2) }],
|
|
198
|
+
rows: [{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1) }, { 'root_id': testUuid(2), 'root_$key_id': testUuid(2) }],
|
|
199
199
|
},
|
|
200
200
|
},
|
|
201
201
|
{
|
|
@@ -290,10 +290,10 @@ test('Posts with comment count (one has many)', async () => {
|
|
|
290
290
|
{
|
|
291
291
|
sql: SQL`select
|
|
292
292
|
"root_"."id" as "root_id",
|
|
293
|
-
"root_"."id" as "
|
|
293
|
+
"root_"."id" as "root_$key_id"
|
|
294
294
|
from "public"."post" as "root_"`,
|
|
295
295
|
response: {
|
|
296
|
-
rows: [{ root_id: testUuid(1) }, { root_id: testUuid(2) }],
|
|
296
|
+
rows: [{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1) }, { 'root_id': testUuid(2), 'root_$key_id': testUuid(2) }],
|
|
297
297
|
},
|
|
298
298
|
},
|
|
299
299
|
{
|
|
@@ -360,10 +360,10 @@ test('Posts with paginated comments without count (one has many)', async () => {
|
|
|
360
360
|
{
|
|
361
361
|
sql: SQL`select
|
|
362
362
|
"root_"."id" as "root_id",
|
|
363
|
-
"root_"."id" as "
|
|
363
|
+
"root_"."id" as "root_$key_id"
|
|
364
364
|
from "public"."post" as "root_"`,
|
|
365
365
|
response: {
|
|
366
|
-
rows: [{ root_id: testUuid(1) }, { root_id: testUuid(2) }],
|
|
366
|
+
rows: [{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1) }, { 'root_id': testUuid(2), 'root_$key_id': testUuid(2) }],
|
|
367
367
|
},
|
|
368
368
|
},
|
|
369
369
|
{
|
|
@@ -444,10 +444,10 @@ test('Posts with paginated comments (one has many)', async () => {
|
|
|
444
444
|
{
|
|
445
445
|
sql: SQL`select
|
|
446
446
|
"root_"."id" as "root_id",
|
|
447
|
-
"root_"."id" as "
|
|
447
|
+
"root_"."id" as "root_$key_id"
|
|
448
448
|
from "public"."post" as "root_"`,
|
|
449
449
|
response: {
|
|
450
|
-
rows: [{ root_id: testUuid(1) }],
|
|
450
|
+
rows: [{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1) }],
|
|
451
451
|
},
|
|
452
452
|
},
|
|
453
453
|
{
|
|
@@ -30,24 +30,26 @@ test('Settings with sites (one-has-one inverse)', async () => {
|
|
|
30
30
|
sql: SQL`select
|
|
31
31
|
"root_"."id" as "root_id",
|
|
32
32
|
"root_"."url" as "root_url",
|
|
33
|
-
"root_"."id" as "
|
|
33
|
+
"root_"."id" as "root_$key_id"
|
|
34
34
|
from "public"."site_setting" as "root_"`,
|
|
35
35
|
response: {
|
|
36
36
|
rows: [
|
|
37
37
|
{
|
|
38
|
-
root_id: testUuid(1),
|
|
39
|
-
|
|
38
|
+
'root_id': testUuid(1),
|
|
39
|
+
'root_$key_id': testUuid(1),
|
|
40
|
+
'root_url': 'http://site1.cz',
|
|
40
41
|
},
|
|
41
42
|
{
|
|
42
|
-
root_id: testUuid(3),
|
|
43
|
-
|
|
43
|
+
'root_id': testUuid(3),
|
|
44
|
+
'root_$key_id': testUuid(3),
|
|
45
|
+
'root_url': 'http://site2.cz',
|
|
44
46
|
},
|
|
45
47
|
],
|
|
46
48
|
},
|
|
47
49
|
},
|
|
48
50
|
{
|
|
49
51
|
sql: SQL`select
|
|
50
|
-
"root_"."setting_id" as "
|
|
52
|
+
"root_"."setting_id" as "root_$index_setting",
|
|
51
53
|
"root_"."id" as "root_id",
|
|
52
54
|
"root_"."name" as "root_name"
|
|
53
55
|
from "public"."site" as "root_"
|
|
@@ -56,14 +58,14 @@ test('Settings with sites (one-has-one inverse)', async () => {
|
|
|
56
58
|
response: {
|
|
57
59
|
rows: [
|
|
58
60
|
{
|
|
59
|
-
root_id: testUuid(2),
|
|
60
|
-
|
|
61
|
-
root_name: 'Site 1',
|
|
61
|
+
'root_id': testUuid(2),
|
|
62
|
+
'root_$index_setting': testUuid(1),
|
|
63
|
+
'root_name': 'Site 1',
|
|
62
64
|
},
|
|
63
65
|
{
|
|
64
|
-
root_id: testUuid(4),
|
|
65
|
-
|
|
66
|
-
root_name: 'Site 2',
|
|
66
|
+
'root_id': testUuid(4),
|
|
67
|
+
'root_$index_setting': testUuid(3),
|
|
68
|
+
'root_name': 'Site 2',
|
|
67
69
|
},
|
|
68
70
|
],
|
|
69
71
|
},
|
|
@@ -31,20 +31,20 @@ test('Sites with settings (one-has-one owning)', async () => {
|
|
|
31
31
|
select
|
|
32
32
|
"root_"."id" as "root_id",
|
|
33
33
|
"root_"."name" as "root_name",
|
|
34
|
-
"root_"."setting_id" as "
|
|
34
|
+
"root_"."setting_id" as "root_$key_setting"
|
|
35
35
|
from "public"."site" as "root_"`,
|
|
36
36
|
|
|
37
37
|
response: {
|
|
38
38
|
rows: [
|
|
39
39
|
{
|
|
40
|
-
root_id: testUuid(1),
|
|
41
|
-
root_name: 'Site 1',
|
|
42
|
-
|
|
40
|
+
'root_id': testUuid(1),
|
|
41
|
+
'root_name': 'Site 1',
|
|
42
|
+
'root_$key_setting': testUuid(2),
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
|
-
root_id: testUuid(3),
|
|
46
|
-
root_name: 'Site 2',
|
|
47
|
-
|
|
45
|
+
'root_id': testUuid(3),
|
|
46
|
+
'root_name': 'Site 2',
|
|
47
|
+
'root_$key_setting': testUuid(4),
|
|
48
48
|
},
|
|
49
49
|
],
|
|
50
50
|
},
|
|
@@ -52,7 +52,7 @@ test('Sites with settings (one-has-one owning)', async () => {
|
|
|
52
52
|
{
|
|
53
53
|
sql: SQL`
|
|
54
54
|
select
|
|
55
|
-
"root_"."id" as "
|
|
55
|
+
"root_"."id" as "root_$index_id",
|
|
56
56
|
"root_"."id" as "root_id",
|
|
57
57
|
"root_"."url" as "root_url"
|
|
58
58
|
from "public"."site_setting" as "root_"
|
|
@@ -62,12 +62,14 @@ test('Sites with settings (one-has-one owning)', async () => {
|
|
|
62
62
|
response: {
|
|
63
63
|
rows: [
|
|
64
64
|
{
|
|
65
|
-
root_id: testUuid(2),
|
|
66
|
-
|
|
65
|
+
'root_id': testUuid(2),
|
|
66
|
+
'root_$index_id': testUuid(2),
|
|
67
|
+
'root_url': 'http://site1.cz',
|
|
67
68
|
},
|
|
68
69
|
{
|
|
69
|
-
root_id: testUuid(4),
|
|
70
|
-
|
|
70
|
+
'root_id': testUuid(4),
|
|
71
|
+
'root_$index_id': testUuid(4),
|
|
72
|
+
'root_url': 'http://site2.cz',
|
|
71
73
|
},
|
|
72
74
|
],
|
|
73
75
|
},
|
|
@@ -28,10 +28,10 @@ test('one has many - default ordering', async () => {
|
|
|
28
28
|
}`,
|
|
29
29
|
executes: [
|
|
30
30
|
{
|
|
31
|
-
sql: SQL`select "root_"."id" as "root_id", "root_"."id" as "
|
|
31
|
+
sql: SQL`select "root_"."id" as "root_id", "root_"."id" as "root_$key_id" from "public"."menu" as "root_"`,
|
|
32
32
|
parameters: [],
|
|
33
33
|
response: {
|
|
34
|
-
rows: [{ root_id: testUuid(1) }, { root_id: testUuid(2) }],
|
|
34
|
+
rows: [{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1) }, { 'root_id': testUuid(2), 'root_$key_id': testUuid(2) }],
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
37
|
{
|
|
@@ -96,10 +96,10 @@ test('many has many - default ordering', async () => {
|
|
|
96
96
|
}`,
|
|
97
97
|
executes: [
|
|
98
98
|
{
|
|
99
|
-
sql: SQL`select "root_"."id" as "root_id", "root_"."id" as "
|
|
99
|
+
sql: SQL`select "root_"."id" as "root_id", "root_"."id" as "root_$key_id" from "public"."post" as "root_"`,
|
|
100
100
|
parameters: [],
|
|
101
101
|
response: {
|
|
102
|
-
rows: [{ root_id: testUuid(1) }, { root_id: testUuid(2) }],
|
|
102
|
+
rows: [{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1) }, { 'root_id': testUuid(2), 'root_$key_id': testUuid(2) }],
|
|
103
103
|
},
|
|
104
104
|
},
|
|
105
105
|
{
|
|
@@ -117,13 +117,13 @@ test('sorts posts by random on has many relation', async () => {
|
|
|
117
117
|
sql: SQL`select
|
|
118
118
|
"root_"."id" as "root_id",
|
|
119
119
|
"root_"."title" as "root_title",
|
|
120
|
-
"root_"."id" as "
|
|
120
|
+
"root_"."id" as "root_$key_id"
|
|
121
121
|
from "public"."category" as "root_"`,
|
|
122
122
|
parameters: [],
|
|
123
123
|
response: {
|
|
124
124
|
rows: [
|
|
125
|
-
{ root_id: testUuid(1), root_title: 'Hello' },
|
|
126
|
-
{ root_id: testUuid(2), root_title: 'World' },
|
|
125
|
+
{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1), 'root_title': 'Hello' },
|
|
126
|
+
{ 'root_id': testUuid(2), 'root_$key_id': testUuid(2), 'root_title': 'World' },
|
|
127
127
|
],
|
|
128
128
|
},
|
|
129
129
|
},
|
|
@@ -22,10 +22,10 @@ test('Post with ordered locales', async () => {
|
|
|
22
22
|
{
|
|
23
23
|
sql: SQL`select
|
|
24
24
|
"root_"."id" as "root_id",
|
|
25
|
-
"root_"."id" as "
|
|
25
|
+
"root_"."id" as "root_$key_id"
|
|
26
26
|
from "public"."post" as "root_"`,
|
|
27
27
|
response: {
|
|
28
|
-
rows: [{ root_id: testUuid(1) }, { root_id: testUuid(2) }],
|
|
28
|
+
rows: [{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1) }, { 'root_id': testUuid(2), 'root_$key_id': testUuid(2) }],
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
31
|
{
|
|
@@ -31,33 +31,33 @@ test('query a view through a relation', async () => {
|
|
|
31
31
|
}`,
|
|
32
32
|
executes: [
|
|
33
33
|
{
|
|
34
|
-
sql: SQL`select "root_"."name" as "root_name", "root_"."id" as "
|
|
34
|
+
sql: SQL`select "root_"."name" as "root_name", "root_"."id" as "root_$key_id", "root_"."id" as "root_id"
|
|
35
35
|
from "public"."author" as "root_"`,
|
|
36
36
|
response: {
|
|
37
37
|
rows: [
|
|
38
|
-
{ root_id: testUuid(1), root_name: 'John' },
|
|
39
|
-
{ root_id: testUuid(2), root_name: 'Jack' },
|
|
38
|
+
{ 'root_id': testUuid(1), 'root_$key_id': testUuid(1), 'root_name': 'John' },
|
|
39
|
+
{ 'root_id': testUuid(2), 'root_$key_id': testUuid(2), 'root_name': 'Jack' },
|
|
40
40
|
],
|
|
41
41
|
},
|
|
42
42
|
parameters: [],
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
sql: SQL`
|
|
46
|
-
select "root_"."author_id" as "
|
|
46
|
+
select "root_"."author_id" as "root_$index_author", "root_"."post_count" as "root_postCount", "root_"."id" as "root_id"
|
|
47
47
|
from "public"."author_stats" as "root_"
|
|
48
48
|
where "root_"."author_id" in (?, ?)`,
|
|
49
49
|
parameters: [testUuid(1), testUuid(2)],
|
|
50
50
|
response: {
|
|
51
51
|
rows: [
|
|
52
52
|
{
|
|
53
|
-
root_id: null,
|
|
54
|
-
|
|
55
|
-
root_postCount: 2,
|
|
53
|
+
'root_id': null,
|
|
54
|
+
'root_$index_author': testUuid(1),
|
|
55
|
+
'root_postCount': 2,
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
|
-
root_id: null,
|
|
59
|
-
|
|
60
|
-
root_postCount: 3,
|
|
58
|
+
'root_id': null,
|
|
59
|
+
'root_$index_author': testUuid(2),
|
|
60
|
+
'root_postCount': 3,
|
|
61
61
|
},
|
|
62
62
|
],
|
|
63
63
|
},
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test'
|
|
2
|
+
import { emptyDatabaseMetadata, QueryError } from '@contember/database'
|
|
3
|
+
import { createLogger, TestLoggerHandler, withLogger } from '@contember/logger'
|
|
4
|
+
import { emptySchema } from '@contember/schema-utils'
|
|
5
|
+
import { convertError, MutationSqlError } from '../../../src/mapper'
|
|
6
|
+
|
|
7
|
+
const convert = (code: string, message: string) => {
|
|
8
|
+
const error = new QueryError('select 1', [], Object.assign(new Error(message), { code }))
|
|
9
|
+
const handler = new TestLoggerHandler()
|
|
10
|
+
const result = withLogger(createLogger(handler), () => convertError(emptySchema.model, emptyDatabaseMetadata, error))
|
|
11
|
+
if (!(result instanceof MutationSqlError)) {
|
|
12
|
+
throw new Error('expected a MutationSqlError')
|
|
13
|
+
}
|
|
14
|
+
return { message: result.message, logged: handler.messages.map(it => it.error), error }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
describe('mutation SQL error', () => {
|
|
18
|
+
it('returns a generic message for an error that can quote internal identifiers, and logs the original', () => {
|
|
19
|
+
const { message, logged, error } = convert('42702', 'column reference "root_$predicate_rule" is ambiguous')
|
|
20
|
+
expect(message).toBe('Database query failed')
|
|
21
|
+
expect(logged).toContain(error)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('keeps the message of data, integrity and trigger errors', () => {
|
|
25
|
+
expect(convert('23514', 'new row for relation "order" violates check constraint "order_total_check"').message)
|
|
26
|
+
.toBe('new row for relation "order" violates check constraint "order_total_check"')
|
|
27
|
+
expect(convert('22001', 'value too long for type character varying(10)').message).toBe('value too long for type character varying(10)')
|
|
28
|
+
expect(convert('P0001', 'Order total must be positive').message).toBe('Order total must be positive')
|
|
29
|
+
})
|
|
30
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test'
|
|
2
|
+
import { PathFactory } from '../../../src/mapper'
|
|
3
|
+
|
|
4
|
+
describe('select path aliases', () => {
|
|
5
|
+
it('keep engine-owned columns apart from field aliases after truncation', () => {
|
|
6
|
+
const factory = new PathFactory()
|
|
7
|
+
const name = 'p'.repeat(80)
|
|
8
|
+
const internal = factory.create([]).forInternal('predicate').for(name).alias
|
|
9
|
+
const field = factory.create([]).for(name).for(name).alias
|
|
10
|
+
expect(internal.length).toBe(63)
|
|
11
|
+
expect(field.length).toBe(63)
|
|
12
|
+
expect(field).not.toBe(internal)
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('stay unique within the PostgreSQL byte limit for multi-byte names', () => {
|
|
16
|
+
const factory = new PathFactory()
|
|
17
|
+
const name = 'x' + 'é'.repeat(23)
|
|
18
|
+
// 63 and 64 bytes untruncated: PostgreSQL would cut the second to the first
|
|
19
|
+
const first = factory.create([]).forInternal('predicate').for(name).alias
|
|
20
|
+
const second = factory.create([]).forInternal('predicate').for(name + 'x').alias
|
|
21
|
+
const encoder = new TextEncoder()
|
|
22
|
+
expect(encoder.encode(first).length).toBe(63)
|
|
23
|
+
expect(encoder.encode(second).length).toBe(63)
|
|
24
|
+
expect(second).not.toBe(first)
|
|
25
|
+
})
|
|
26
|
+
})
|