@payloadcms/db-postgres 3.0.0-canary.92e4997 → 3.0.0-canary.c13f9ba

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. package/dist/connect.d.ts.map +1 -1
  2. package/dist/connect.js +12 -7
  3. package/dist/connect.js.map +1 -1
  4. package/dist/count.d.ts.map +1 -1
  5. package/dist/count.js +1 -10
  6. package/dist/count.js.map +1 -1
  7. package/dist/createMigration.d.ts.map +1 -1
  8. package/dist/createMigration.js +58 -37
  9. package/dist/createMigration.js.map +1 -1
  10. package/dist/createVersion.d.ts.map +1 -1
  11. package/dist/createVersion.js +2 -6
  12. package/dist/createVersion.js.map +1 -1
  13. package/dist/deleteOne.js +2 -2
  14. package/dist/deleteOne.js.map +1 -1
  15. package/dist/destroy.d.ts.map +1 -1
  16. package/dist/destroy.js +4 -0
  17. package/dist/destroy.js.map +1 -1
  18. package/dist/exports/migration-utils.d.ts +2 -0
  19. package/dist/exports/migration-utils.d.ts.map +1 -0
  20. package/dist/exports/migration-utils.js +3 -0
  21. package/dist/exports/migration-utils.js.map +1 -0
  22. package/dist/find/buildFindManyArgs.d.ts +5 -1
  23. package/dist/find/buildFindManyArgs.d.ts.map +1 -1
  24. package/dist/find/buildFindManyArgs.js +2 -1
  25. package/dist/find/buildFindManyArgs.js.map +1 -1
  26. package/dist/find/findMany.d.ts.map +1 -1
  27. package/dist/find/findMany.js +4 -15
  28. package/dist/find/findMany.js.map +1 -1
  29. package/dist/find/traverseFields.d.ts +3 -2
  30. package/dist/find/traverseFields.d.ts.map +1 -1
  31. package/dist/find/traverseFields.js +22 -4
  32. package/dist/find/traverseFields.js.map +1 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +9 -0
  35. package/dist/index.js.map +1 -1
  36. package/dist/init.d.ts.map +1 -1
  37. package/dist/init.js +14 -19
  38. package/dist/init.js.map +1 -1
  39. package/dist/predefinedMigrations/relationships-v2-v3.d.ts +4 -0
  40. package/dist/predefinedMigrations/relationships-v2-v3.d.ts.map +1 -0
  41. package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -0
  42. package/dist/predefinedMigrations/relationships-v2-v3.mjs +11 -0
  43. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +20 -0
  44. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -0
  45. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +170 -0
  46. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -0
  47. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts +11 -0
  48. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -0
  49. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +191 -0
  50. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -0
  51. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts +3 -0
  52. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -0
  53. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js +56 -0
  54. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js.map +1 -0
  55. package/dist/predefinedMigrations/v2-v3/index.d.ts +24 -0
  56. package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -0
  57. package/dist/predefinedMigrations/v2-v3/index.js +211 -0
  58. package/dist/predefinedMigrations/v2-v3/index.js.map +1 -0
  59. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +19 -0
  60. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -0
  61. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js +57 -0
  62. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -0
  63. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +23 -0
  64. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -0
  65. package/dist/predefinedMigrations/v2-v3/traverseFields.js +85 -0
  66. package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -0
  67. package/dist/predefinedMigrations/v2-v3/types.d.ts +9 -0
  68. package/dist/predefinedMigrations/v2-v3/types.d.ts.map +1 -0
  69. package/dist/predefinedMigrations/v2-v3/types.js +6 -0
  70. package/dist/predefinedMigrations/v2-v3/types.js.map +1 -0
  71. package/dist/queries/buildAndOrConditions.d.ts +3 -4
  72. package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
  73. package/dist/queries/buildAndOrConditions.js +1 -2
  74. package/dist/queries/buildAndOrConditions.js.map +1 -1
  75. package/dist/queries/buildQuery.d.ts +1 -2
  76. package/dist/queries/buildQuery.d.ts.map +1 -1
  77. package/dist/queries/buildQuery.js +1 -5
  78. package/dist/queries/buildQuery.js.map +1 -1
  79. package/dist/queries/getTableColumnFromPath.d.ts +3 -4
  80. package/dist/queries/getTableColumnFromPath.d.ts.map +1 -1
  81. package/dist/queries/getTableColumnFromPath.js +168 -96
  82. package/dist/queries/getTableColumnFromPath.js.map +1 -1
  83. package/dist/queries/parseParams.d.ts +3 -4
  84. package/dist/queries/parseParams.d.ts.map +1 -1
  85. package/dist/queries/parseParams.js +7 -6
  86. package/dist/queries/parseParams.js.map +1 -1
  87. package/dist/queries/selectDistinct.d.ts +3 -4
  88. package/dist/queries/selectDistinct.d.ts.map +1 -1
  89. package/dist/queries/selectDistinct.js +3 -14
  90. package/dist/queries/selectDistinct.js.map +1 -1
  91. package/dist/schema/build.d.ts +8 -4
  92. package/dist/schema/build.d.ts.map +1 -1
  93. package/dist/schema/build.js +161 -112
  94. package/dist/schema/build.js.map +1 -1
  95. package/dist/schema/traverseFields.d.ts +4 -6
  96. package/dist/schema/traverseFields.d.ts.map +1 -1
  97. package/dist/schema/traverseFields.js +103 -40
  98. package/dist/schema/traverseFields.js.map +1 -1
  99. package/dist/transactions/beginTransaction.d.ts.map +1 -1
  100. package/dist/transactions/beginTransaction.js +4 -0
  101. package/dist/transactions/beginTransaction.js.map +1 -1
  102. package/dist/transform/read/index.d.ts +3 -1
  103. package/dist/transform/read/index.d.ts.map +1 -1
  104. package/dist/transform/read/index.js +2 -1
  105. package/dist/transform/read/index.js.map +1 -1
  106. package/dist/transform/read/relationship.d.ts.map +1 -1
  107. package/dist/transform/read/relationship.js +0 -4
  108. package/dist/transform/read/relationship.js.map +1 -1
  109. package/dist/transform/read/traverseFields.d.ts +6 -1
  110. package/dist/transform/read/traverseFields.d.ts.map +1 -1
  111. package/dist/transform/read/traverseFields.js +69 -55
  112. package/dist/transform/read/traverseFields.js.map +1 -1
  113. package/dist/transform/write/traverseFields.d.ts.map +1 -1
  114. package/dist/transform/write/traverseFields.js +20 -3
  115. package/dist/transform/write/traverseFields.js.map +1 -1
  116. package/dist/types.d.ts +3 -0
  117. package/dist/types.d.ts.map +1 -1
  118. package/dist/types.js.map +1 -1
  119. package/dist/update.d.ts.map +1 -1
  120. package/dist/update.js +1 -2
  121. package/dist/update.js.map +1 -1
  122. package/dist/upsertRow/index.d.ts +1 -1
  123. package/dist/upsertRow/index.d.ts.map +1 -1
  124. package/dist/upsertRow/index.js +3 -1
  125. package/dist/upsertRow/index.js.map +1 -1
  126. package/dist/upsertRow/types.d.ts +5 -0
  127. package/dist/upsertRow/types.d.ts.map +1 -1
  128. package/dist/upsertRow/types.js.map +1 -1
  129. package/package.json +12 -6
@@ -9,7 +9,7 @@ import { v4 as uuid } from 'uuid';
9
9
  * Transforms path to table and column name
10
10
  * Adds tables to `join`
11
11
  * @returns TableColumn
12
- */ export const getTableColumnFromPath = ({ adapter, aliasTable, collectionPath, columnPrefix = '', constraintPath: incomingConstraintPath, constraints = [], fields, joinAliases, joins, locale: incomingLocale, pathSegments: incomingSegments, rootTableName: incomingRootTableName, selectFields, tableName, tableNameSuffix = '', value })=>{
12
+ */ export const getTableColumnFromPath = ({ adapter, aliasTable, collectionPath, columnPrefix = '', constraintPath: incomingConstraintPath, constraints = [], fields, joins, locale: incomingLocale, pathSegments: incomingSegments, rootTableName: incomingRootTableName, selectFields, tableName, tableNameSuffix = '', value })=>{
13
13
  const fieldPath = incomingSegments[0];
14
14
  let locale = incomingLocale;
15
15
  const rootTableName = incomingRootTableName || tableName;
@@ -55,7 +55,6 @@ import { v4 as uuid } from 'uuid';
55
55
  ...tab,
56
56
  type: 'tab'
57
57
  })),
58
- joinAliases,
59
58
  joins,
60
59
  locale,
61
60
  pathSegments: pathSegments.slice(1),
@@ -77,7 +76,6 @@ import { v4 as uuid } from 'uuid';
77
76
  constraintPath: `${constraintPath}${field.name}.`,
78
77
  constraints,
79
78
  fields: field.fields,
80
- joinAliases,
81
79
  joins,
82
80
  locale,
83
81
  pathSegments: pathSegments.slice(1),
@@ -96,7 +94,6 @@ import { v4 as uuid } from 'uuid';
96
94
  constraintPath,
97
95
  constraints,
98
96
  fields: field.fields,
99
- joinAliases,
100
97
  joins,
101
98
  locale,
102
99
  pathSegments: pathSegments.slice(1),
@@ -111,7 +108,10 @@ import { v4 as uuid } from 'uuid';
111
108
  {
112
109
  if (locale && field.localized && adapter.payload.config.localization) {
113
110
  newTableName = `${tableName}${adapter.localesSuffix}`;
114
- joins[tableName] = eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID);
111
+ joins.push({
112
+ condition: eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID),
113
+ table: adapter.tables[newTableName]
114
+ });
115
115
  if (locale !== 'all') {
116
116
  constraints.push({
117
117
  columnName: '_locale',
@@ -128,7 +128,6 @@ import { v4 as uuid } from 'uuid';
128
128
  constraintPath: `${constraintPath}${field.name}.`,
129
129
  constraints,
130
130
  fields: field.fields,
131
- joinAliases,
132
131
  joins,
133
132
  locale,
134
133
  pathSegments: pathSegments.slice(1),
@@ -144,7 +143,10 @@ import { v4 as uuid } from 'uuid';
144
143
  if (field.hasMany) {
145
144
  const newTableName = adapter.tableNameMap.get(`${tableName}_${tableNameSuffix}${toSnakeCase(field.name)}`);
146
145
  if (locale && field.localized && adapter.payload.config.localization) {
147
- joins[newTableName] = and(eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent), eq(adapter.tables[newTableName]._locale, locale));
146
+ joins.push({
147
+ condition: and(eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent), eq(adapter.tables[newTableName]._locale, locale)),
148
+ table: adapter.tables[newTableName]
149
+ });
148
150
  if (locale !== 'all') {
149
151
  constraints.push({
150
152
  columnName: '_locale',
@@ -153,7 +155,10 @@ import { v4 as uuid } from 'uuid';
153
155
  });
154
156
  }
155
157
  } else {
156
- joins[newTableName] = eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent);
158
+ joins.push({
159
+ condition: eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent),
160
+ table: adapter.tables[newTableName]
161
+ });
157
162
  }
158
163
  return {
159
164
  columnName: 'value',
@@ -180,7 +185,10 @@ import { v4 as uuid } from 'uuid';
180
185
  eq(adapter.tables[newTableName].path, `${constraintPath}${field.name}`)
181
186
  ];
182
187
  if (locale && field.localized && adapter.payload.config.localization) {
183
- joins[newTableName] = and(...joinConstraints, eq(adapter.tables[newTableName]._locale, locale));
188
+ joins.push({
189
+ condition: and(...joinConstraints, eq(adapter.tables[newTableName]._locale, locale)),
190
+ table: adapter.tables[newTableName]
191
+ });
184
192
  if (locale !== 'all') {
185
193
  constraints.push({
186
194
  columnName: 'locale',
@@ -189,7 +197,10 @@ import { v4 as uuid } from 'uuid';
189
197
  });
190
198
  }
191
199
  } else {
192
- joins[newTableName] = and(...joinConstraints);
200
+ joins.push({
201
+ condition: and(...joinConstraints),
202
+ table: adapter.tables[newTableName]
203
+ });
193
204
  }
194
205
  return {
195
206
  columnName,
@@ -205,7 +216,10 @@ import { v4 as uuid } from 'uuid';
205
216
  newTableName = adapter.tableNameMap.get(`${tableName}_${tableNameSuffix}${toSnakeCase(field.name)}`);
206
217
  constraintPath = `${constraintPath}${field.name}.%.`;
207
218
  if (locale && field.localized && adapter.payload.config.localization) {
208
- joins[newTableName] = and(eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID), eq(adapter.tables[newTableName]._locale, locale));
219
+ joins.push({
220
+ condition: and(eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID), eq(adapter.tables[newTableName]._locale, locale)),
221
+ table: adapter.tables[newTableName]
222
+ });
209
223
  if (locale !== 'all') {
210
224
  constraints.push({
211
225
  columnName: '_locale',
@@ -214,7 +228,10 @@ import { v4 as uuid } from 'uuid';
214
228
  });
215
229
  }
216
230
  } else {
217
- joins[newTableName] = eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID);
231
+ joins.push({
232
+ condition: eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID),
233
+ table: adapter.tables[newTableName]
234
+ });
218
235
  }
219
236
  return getTableColumnFromPath({
220
237
  adapter,
@@ -222,7 +239,6 @@ import { v4 as uuid } from 'uuid';
222
239
  constraintPath,
223
240
  constraints,
224
241
  fields: field.fields,
225
- joinAliases,
226
242
  joins,
227
243
  locale,
228
244
  pathSegments: pathSegments.slice(1),
@@ -245,10 +261,15 @@ import { v4 as uuid } from 'uuid';
245
261
  blockTypes.forEach((blockType)=>{
246
262
  const block = field.blocks.find((block)=>block.slug === blockType);
247
263
  newTableName = adapter.tableNameMap.get(`${tableName}_blocks_${toSnakeCase(block.slug)}`);
248
- joins[newTableName] = eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID);
264
+ const newAliasTableName = toSnakeCase(uuid());
265
+ const newAliasTable = alias(adapter.tables[newTableName], newAliasTableName);
266
+ joins.push({
267
+ condition: eq(adapter.tables[tableName].id, newAliasTable._parentID),
268
+ table: newAliasTable
269
+ });
249
270
  constraints.push({
250
271
  columnName: '_path',
251
- table: adapter.tables[newTableName],
272
+ table: newAliasTable,
252
273
  value: pathSegments[0]
253
274
  });
254
275
  });
@@ -272,7 +293,6 @@ import { v4 as uuid } from 'uuid';
272
293
  constraintPath,
273
294
  constraints: blockConstraints,
274
295
  fields: block.fields,
275
- joinAliases,
276
296
  joins,
277
297
  locale,
278
298
  pathSegments: pathSegments.slice(1),
@@ -294,7 +314,10 @@ import { v4 as uuid } from 'uuid';
294
314
  ...blockSelectFields
295
315
  };
296
316
  if (field.localized && adapter.payload.config.localization) {
297
- joins[newTableName] = and(eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID), eq(adapter.tables[newTableName]._locale, locale));
317
+ joins.push({
318
+ condition: and(eq((aliasTable || adapter.tables[tableName]).id, adapter.tables[newTableName]._parentID), eq(adapter.tables[newTableName]._locale, locale)),
319
+ table: adapter.tables[newTableName]
320
+ });
298
321
  if (locale) {
299
322
  constraints.push({
300
323
  columnName: '_locale',
@@ -303,7 +326,10 @@ import { v4 as uuid } from 'uuid';
303
326
  });
304
327
  }
305
328
  } else {
306
- joins[newTableName] = eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID);
329
+ joins.push({
330
+ condition: eq((aliasTable || adapter.tables[tableName]).id, adapter.tables[newTableName]._parentID),
331
+ table: adapter.tables[newTableName]
332
+ });
307
333
  }
308
334
  return true;
309
335
  });
@@ -322,103 +348,149 @@ import { v4 as uuid } from 'uuid';
322
348
  case 'relationship':
323
349
  case 'upload':
324
350
  {
325
- let relationshipFields;
326
- const relationTableName = `${rootTableName}${adapter.relationshipsSuffix}`;
327
351
  const newCollectionPath = pathSegments.slice(1).join('.');
328
- const aliasRelationshipTableName = uuid();
329
- const aliasRelationshipTable = alias(adapter.tables[relationTableName], aliasRelationshipTableName);
330
- // Join in the relationships table
331
- if (locale && field.localized && adapter.payload.config.localization) {
332
- joinAliases.push({
333
- condition: and(eq((aliasTable || adapter.tables[rootTableName]).id, aliasRelationshipTable.parent), eq(aliasRelationshipTable.locale, locale), like(aliasRelationshipTable.path, `${constraintPath}${field.name}`)),
334
- table: aliasRelationshipTable
335
- });
336
- if (locale !== 'all') {
337
- constraints.push({
338
- columnName: 'locale',
339
- table: aliasRelationshipTable,
340
- value: locale
352
+ if (Array.isArray(field.relationTo) || field.type === 'relationship' && field.hasMany) {
353
+ let relationshipFields;
354
+ const relationTableName = `${rootTableName}${adapter.relationshipsSuffix}`;
355
+ const aliasRelationshipTableName = uuid();
356
+ const aliasRelationshipTable = alias(adapter.tables[relationTableName], aliasRelationshipTableName);
357
+ // Join in the relationships table
358
+ if (locale && field.localized && adapter.payload.config.localization) {
359
+ joins.push({
360
+ condition: and(eq((aliasTable || adapter.tables[rootTableName]).id, aliasRelationshipTable.parent), eq(aliasRelationshipTable.locale, locale), like(aliasRelationshipTable.path, `${constraintPath}${field.name}`)),
361
+ table: aliasRelationshipTable
362
+ });
363
+ if (locale !== 'all') {
364
+ constraints.push({
365
+ columnName: 'locale',
366
+ table: aliasRelationshipTable,
367
+ value: locale
368
+ });
369
+ }
370
+ } else {
371
+ // Join in the relationships table
372
+ joins.push({
373
+ condition: and(eq((aliasTable || adapter.tables[rootTableName]).id, aliasRelationshipTable.parent), like(aliasRelationshipTable.path, `${constraintPath}${field.name}`)),
374
+ table: aliasRelationshipTable
341
375
  });
342
376
  }
343
- } else {
344
- // Join in the relationships table
345
- joinAliases.push({
346
- condition: and(eq((aliasTable || adapter.tables[rootTableName]).id, aliasRelationshipTable.parent), like(aliasRelationshipTable.path, `${constraintPath}${field.name}`)),
347
- table: aliasRelationshipTable
348
- });
349
- }
350
- selectFields[`${relationTableName}.path`] = aliasRelationshipTable.path;
351
- let newAliasTable;
352
- if (typeof field.relationTo === 'string') {
353
- const relationshipConfig = adapter.payload.collections[field.relationTo].config;
354
- newTableName = adapter.tableNameMap.get(toSnakeCase(relationshipConfig.slug));
355
- // parent to relationship join table
356
- relationshipFields = relationshipConfig.fields;
357
- newAliasTable = alias(adapter.tables[newTableName], toSnakeCase(uuid()));
358
- joinAliases.push({
359
- condition: eq(newAliasTable.id, aliasRelationshipTable[`${field.relationTo}ID`]),
360
- table: newAliasTable
361
- });
362
- if (newCollectionPath === '' || newCollectionPath === 'id') {
377
+ selectFields[`${relationTableName}.path`] = aliasRelationshipTable.path;
378
+ let newAliasTable;
379
+ if (typeof field.relationTo === 'string') {
380
+ const relationshipConfig = adapter.payload.collections[field.relationTo].config;
381
+ newTableName = adapter.tableNameMap.get(toSnakeCase(relationshipConfig.slug));
382
+ // parent to relationship join table
383
+ relationshipFields = relationshipConfig.fields;
384
+ newAliasTable = alias(adapter.tables[newTableName], toSnakeCase(uuid()));
385
+ joins.push({
386
+ condition: eq(newAliasTable.id, aliasRelationshipTable[`${field.relationTo}ID`]),
387
+ table: newAliasTable
388
+ });
389
+ if (newCollectionPath === '' || newCollectionPath === 'id') {
390
+ return {
391
+ columnName: `${field.relationTo}ID`,
392
+ constraints,
393
+ field,
394
+ table: aliasRelationshipTable
395
+ };
396
+ }
397
+ } else if (newCollectionPath === 'value') {
398
+ const tableColumnsNames = field.relationTo.map((relationTo)=>{
399
+ const relationTableName = adapter.tableNameMap.get(toSnakeCase(adapter.payload.collections[relationTo].config.slug));
400
+ return `"${aliasRelationshipTableName}"."${relationTableName}_id"`;
401
+ });
363
402
  return {
364
- columnName: `${field.relationTo}ID`,
365
403
  constraints,
366
404
  field,
405
+ rawColumn: sql.raw(`COALESCE(${tableColumnsNames.join(', ')})`),
367
406
  table: aliasRelationshipTable
368
407
  };
408
+ } else if (newCollectionPath === 'relationTo') {
409
+ const relationTo = Array.isArray(field.relationTo) ? field.relationTo : [
410
+ field.relationTo
411
+ ];
412
+ return {
413
+ constraints,
414
+ field,
415
+ getNotNullColumnByValue: (val)=>{
416
+ const matchedRelation = relationTo.find((relation)=>relation === val);
417
+ if (matchedRelation) return `${matchedRelation}ID`;
418
+ return undefined;
419
+ },
420
+ table: aliasRelationshipTable
421
+ };
422
+ } else {
423
+ throw new APIError('Not supported');
369
424
  }
370
- } else if (newCollectionPath === 'value') {
371
- const tableColumnsNames = field.relationTo.map((relationTo)=>{
372
- const relationTableName = adapter.tableNameMap.get(toSnakeCase(adapter.payload.collections[relationTo].config.slug));
373
- return `"${aliasRelationshipTableName}"."${relationTableName}_id"`;
374
- });
375
- return {
425
+ return getTableColumnFromPath({
426
+ adapter,
427
+ aliasTable: newAliasTable,
428
+ collectionPath: newCollectionPath,
376
429
  constraints,
377
- field,
378
- rawColumn: sql.raw(`COALESCE(${tableColumnsNames.join(', ')})`),
379
- table: aliasRelationshipTable
380
- };
381
- } else if (newCollectionPath === 'relationTo') {
382
- const relationTo = Array.isArray(field.relationTo) ? field.relationTo : [
383
- field.relationTo
384
- ];
385
- return {
430
+ fields: relationshipFields,
431
+ joins,
432
+ locale,
433
+ pathSegments: pathSegments.slice(1),
434
+ rootTableName: newTableName,
435
+ selectFields,
436
+ tableName: newTableName,
437
+ value
438
+ });
439
+ } else if (pathSegments.length > 1 && !(pathSegments.length === 2 && pathSegments[1] === 'id')) {
440
+ // simple relationships
441
+ const columnName = `${columnPrefix}${field.name}`;
442
+ const newTableName = adapter.tableNameMap.get(toSnakeCase(adapter.payload.collections[field.relationTo].config.slug));
443
+ const aliasTableName = uuid();
444
+ const newAliasTable = alias(adapter.tables[newTableName], aliasTableName);
445
+ if (field.localized && adapter.payload.config.localization) {
446
+ const aliasLocaleTableName = uuid();
447
+ const aliasLocaleTable = alias(adapter.tables[`${rootTableName}${adapter.localesSuffix}`], aliasLocaleTableName);
448
+ joins.push({
449
+ condition: and(eq(aliasLocaleTable._parentID, adapter.tables[rootTableName].id), eq(aliasLocaleTable._locale, locale)),
450
+ table: aliasLocaleTable
451
+ });
452
+ joins.push({
453
+ condition: eq(aliasLocaleTable[columnName], newAliasTable.id),
454
+ table: newAliasTable
455
+ });
456
+ } else {
457
+ joins.push({
458
+ condition: eq(newAliasTable.id, aliasTable ? aliasTable[columnName] : adapter.tables[tableName][columnName]),
459
+ table: newAliasTable
460
+ });
461
+ }
462
+ return getTableColumnFromPath({
463
+ adapter,
464
+ aliasTable: newAliasTable,
465
+ collectionPath: newCollectionPath,
466
+ constraintPath: '',
386
467
  constraints,
387
- field,
388
- getNotNullColumnByValue: (val)=>{
389
- const matchedRelation = relationTo.find((relation)=>relation === val);
390
- if (matchedRelation) return `${matchedRelation}ID`;
391
- return undefined;
392
- },
393
- table: aliasRelationshipTable
394
- };
395
- } else {
396
- throw new APIError('Not supported');
468
+ fields: adapter.payload.collections[field.relationTo].config.fields,
469
+ joins,
470
+ locale,
471
+ pathSegments: pathSegments.slice(1),
472
+ selectFields,
473
+ tableName: newTableName,
474
+ value
475
+ });
397
476
  }
398
- return getTableColumnFromPath({
399
- adapter,
400
- aliasTable: newAliasTable,
401
- collectionPath: newCollectionPath,
402
- constraints,
403
- fields: relationshipFields,
404
- joinAliases,
405
- joins,
406
- locale,
407
- pathSegments: pathSegments.slice(1),
408
- rootTableName: newTableName,
409
- selectFields,
410
- tableName: newTableName,
411
- value
412
- });
477
+ break;
478
+ }
479
+ default:
480
+ {
481
+ break;
413
482
  }
414
483
  }
415
484
  if (fieldAffectsData(field)) {
416
485
  if (field.localized && adapter.payload.config.localization) {
417
486
  // If localized, we go to localized table and set aliasTable to undefined
418
487
  // so it is not picked up below to be used as targetTable
419
- newTableName = `${tableName}${adapter.localesSuffix}`;
420
488
  const parentTable = aliasTable || adapter.tables[tableName];
421
- joins[newTableName] = eq(parentTable.id, adapter.tables[newTableName]._parentID);
489
+ newTableName = `${tableName}${adapter.localesSuffix}`;
490
+ joins.push({
491
+ condition: eq(parentTable.id, adapter.tables[newTableName]._parentID),
492
+ table: adapter.tables[newTableName]
493
+ });
422
494
  aliasTable = undefined;
423
495
  if (locale !== 'all') {
424
496
  constraints.push({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/queries/getTableColumnFromPath.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { SQL } from 'drizzle-orm'\nimport type { PgTableWithColumns } from 'drizzle-orm/pg-core'\nimport type { Field, FieldAffectingData, NumberField, TabAsField, TextField } from 'payload/types'\n\nimport { and, eq, like, sql } from 'drizzle-orm'\nimport { alias } from 'drizzle-orm/pg-core'\nimport { APIError } from 'payload/errors'\nimport { fieldAffectsData, tabHasName } from 'payload/types'\nimport { flattenTopLevelFields } from 'payload/utilities'\nimport toSnakeCase from 'to-snake-case'\nimport { v4 as uuid } from 'uuid'\n\nimport type { GenericColumn, GenericTable, PostgresAdapter } from '../types.js'\nimport type { BuildQueryJoinAliases, BuildQueryJoins } from './buildQuery.js'\n\ntype Constraint = {\n columnName: string\n table: GenericTable | PgTableWithColumns<any>\n value: unknown\n}\n\ntype TableColumn = {\n columnName?: string\n constraints: Constraint[]\n field: FieldAffectingData\n getNotNullColumnByValue?: (val: unknown) => string\n pathSegments?: string[]\n rawColumn?: SQL\n table: GenericTable | PgTableWithColumns<any>\n}\n\ntype Args = {\n adapter: PostgresAdapter\n aliasTable?: GenericTable | PgTableWithColumns<any>\n collectionPath: string\n columnPrefix?: string\n constraintPath?: string\n constraints?: Constraint[]\n fields: (Field | TabAsField)[]\n joinAliases: BuildQueryJoinAliases\n joins: BuildQueryJoins\n locale?: string\n pathSegments: string[]\n rootTableName?: string\n selectFields: Record<string, GenericColumn>\n tableName: string\n /**\n * If creating a new table name for arrays and blocks, this suffix should be appended to the table name\n */\n tableNameSuffix?: string\n /**\n * The raw value of the query before sanitization\n */\n value: unknown\n}\n/**\n * Transforms path to table and column name\n * Adds tables to `join`\n * @returns TableColumn\n */\nexport const getTableColumnFromPath = ({\n adapter,\n aliasTable,\n collectionPath,\n columnPrefix = '',\n constraintPath: incomingConstraintPath,\n constraints = [],\n fields,\n joinAliases,\n joins,\n locale: incomingLocale,\n pathSegments: incomingSegments,\n rootTableName: incomingRootTableName,\n selectFields,\n tableName,\n tableNameSuffix = '',\n value,\n}: Args): TableColumn => {\n const fieldPath = incomingSegments[0]\n let locale = incomingLocale\n const rootTableName = incomingRootTableName || tableName\n let constraintPath = incomingConstraintPath || ''\n\n const field = flattenTopLevelFields(fields as Field[]).find(\n (fieldToFind) => fieldAffectsData(fieldToFind) && fieldToFind.name === fieldPath,\n ) as Field | TabAsField\n let newTableName = tableName\n\n if (!field && fieldPath === 'id') {\n selectFields.id = adapter.tables[newTableName].id\n return {\n columnName: 'id',\n constraints,\n field: {\n name: 'id',\n type: adapter.idType === 'uuid' ? 'text' : 'number',\n } as NumberField | TextField,\n table: adapter.tables[newTableName],\n }\n }\n\n if (field) {\n const pathSegments = [...incomingSegments]\n\n // If next segment is a locale,\n // we need to take it out and use it as the locale from this point on\n if ('localized' in field && field.localized && adapter.payload.config.localization) {\n const matchedLocale = adapter.payload.config.localization.localeCodes.find(\n (locale) => locale === pathSegments[1],\n )\n\n if (matchedLocale) {\n locale = matchedLocale\n pathSegments.splice(1, 1)\n }\n }\n\n switch (field.type) {\n case 'tabs': {\n return getTableColumnFromPath({\n adapter,\n aliasTable,\n collectionPath,\n columnPrefix,\n constraintPath,\n constraints,\n fields: field.tabs.map((tab) => ({\n ...tab,\n type: 'tab',\n })),\n joinAliases,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields,\n tableName: newTableName,\n tableNameSuffix,\n value,\n })\n }\n case 'tab': {\n if (tabHasName(field)) {\n return getTableColumnFromPath({\n adapter,\n aliasTable,\n collectionPath,\n columnPrefix: `${columnPrefix}${field.name}_`,\n constraintPath: `${constraintPath}${field.name}.`,\n constraints,\n fields: field.fields,\n joinAliases,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields,\n tableName: newTableName,\n tableNameSuffix: `${tableNameSuffix}${toSnakeCase(field.name)}_`,\n value,\n })\n }\n return getTableColumnFromPath({\n adapter,\n aliasTable,\n collectionPath,\n columnPrefix,\n constraintPath,\n constraints,\n fields: field.fields,\n joinAliases,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields,\n tableName: newTableName,\n tableNameSuffix,\n value,\n })\n }\n\n case 'group': {\n if (locale && field.localized && adapter.payload.config.localization) {\n newTableName = `${tableName}${adapter.localesSuffix}`\n\n joins[tableName] = eq(\n adapter.tables[tableName].id,\n adapter.tables[newTableName]._parentID,\n )\n if (locale !== 'all') {\n constraints.push({\n columnName: '_locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n }\n return getTableColumnFromPath({\n adapter,\n aliasTable,\n collectionPath,\n columnPrefix: `${columnPrefix}${field.name}_`,\n constraintPath: `${constraintPath}${field.name}.`,\n constraints,\n fields: field.fields,\n joinAliases,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields,\n tableName: newTableName,\n tableNameSuffix: `${tableNameSuffix}${toSnakeCase(field.name)}_`,\n value,\n })\n }\n\n case 'select': {\n if (field.hasMany) {\n const newTableName = adapter.tableNameMap.get(\n `${tableName}_${tableNameSuffix}${toSnakeCase(field.name)}`,\n )\n\n if (locale && field.localized && adapter.payload.config.localization) {\n joins[newTableName] = and(\n eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent),\n eq(adapter.tables[newTableName]._locale, locale),\n )\n if (locale !== 'all') {\n constraints.push({\n columnName: '_locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n } else {\n joins[newTableName] = eq(\n adapter.tables[tableName].id,\n adapter.tables[newTableName].parent,\n )\n }\n\n return {\n columnName: 'value',\n constraints,\n field,\n table: adapter.tables[newTableName],\n }\n }\n break\n }\n\n case 'text':\n case 'number': {\n if (field.hasMany) {\n let tableType = 'texts'\n let columnName = 'text'\n if (field.type === 'number') {\n tableType = 'numbers'\n columnName = 'number'\n }\n newTableName = `${tableName}_${tableType}`\n const joinConstraints = [\n eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent),\n eq(adapter.tables[newTableName].path, `${constraintPath}${field.name}`),\n ]\n\n if (locale && field.localized && adapter.payload.config.localization) {\n joins[newTableName] = and(\n ...joinConstraints,\n eq(adapter.tables[newTableName]._locale, locale),\n )\n if (locale !== 'all') {\n constraints.push({\n columnName: 'locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n } else {\n joins[newTableName] = and(...joinConstraints)\n }\n\n return {\n columnName,\n constraints,\n field,\n table: adapter.tables[newTableName],\n }\n }\n break\n }\n\n case 'array': {\n newTableName = adapter.tableNameMap.get(\n `${tableName}_${tableNameSuffix}${toSnakeCase(field.name)}`,\n )\n\n constraintPath = `${constraintPath}${field.name}.%.`\n if (locale && field.localized && adapter.payload.config.localization) {\n joins[newTableName] = and(\n eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID),\n eq(adapter.tables[newTableName]._locale, locale),\n )\n if (locale !== 'all') {\n constraints.push({\n columnName: '_locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n } else {\n joins[newTableName] = eq(\n adapter.tables[tableName].id,\n adapter.tables[newTableName]._parentID,\n )\n }\n return getTableColumnFromPath({\n adapter,\n collectionPath,\n constraintPath,\n constraints,\n fields: field.fields,\n joinAliases,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields,\n tableName: newTableName,\n value,\n })\n }\n\n case 'blocks': {\n let blockTableColumn: TableColumn\n let newTableName: string\n\n // handle blockType queries\n if (pathSegments[1] === 'blockType') {\n // find the block config using the value\n const blockTypes = Array.isArray(value) ? value : [value]\n blockTypes.forEach((blockType) => {\n const block = field.blocks.find((block) => block.slug === blockType)\n\n newTableName = adapter.tableNameMap.get(\n `${tableName}_blocks_${toSnakeCase(block.slug)}`,\n )\n\n joins[newTableName] = eq(\n adapter.tables[tableName].id,\n adapter.tables[newTableName]._parentID,\n )\n constraints.push({\n columnName: '_path',\n table: adapter.tables[newTableName],\n value: pathSegments[0],\n })\n })\n return {\n constraints,\n field,\n getNotNullColumnByValue: () => 'id',\n table: adapter.tables[tableName],\n }\n }\n\n const hasBlockField = field.blocks.some((block) => {\n newTableName = adapter.tableNameMap.get(`${tableName}_blocks_${toSnakeCase(block.slug)}`)\n constraintPath = `${constraintPath}${field.name}.%.`\n\n let result\n const blockConstraints = []\n const blockSelectFields = {}\n try {\n result = getTableColumnFromPath({\n adapter,\n collectionPath,\n constraintPath,\n constraints: blockConstraints,\n fields: block.fields,\n joinAliases,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields: blockSelectFields,\n tableName: newTableName,\n value,\n })\n } catch (error) {\n // this is fine, not every block will have the field\n }\n if (!result) {\n return\n }\n blockTableColumn = result\n constraints = constraints.concat(blockConstraints)\n selectFields = { ...selectFields, ...blockSelectFields }\n if (field.localized && adapter.payload.config.localization) {\n joins[newTableName] = and(\n eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID),\n eq(adapter.tables[newTableName]._locale, locale),\n )\n if (locale) {\n constraints.push({\n columnName: '_locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n } else {\n joins[newTableName] = eq(\n adapter.tables[tableName].id,\n adapter.tables[newTableName]._parentID,\n )\n }\n return true\n })\n if (hasBlockField) {\n return {\n columnName: blockTableColumn.columnName,\n constraints,\n field: blockTableColumn.field,\n pathSegments: pathSegments.slice(1),\n rawColumn: blockTableColumn.rawColumn,\n table: blockTableColumn.table,\n }\n }\n break\n }\n\n case 'relationship':\n case 'upload': {\n let relationshipFields\n const relationTableName = `${rootTableName}${adapter.relationshipsSuffix}`\n const newCollectionPath = pathSegments.slice(1).join('.')\n const aliasRelationshipTableName = uuid()\n const aliasRelationshipTable = alias(\n adapter.tables[relationTableName],\n aliasRelationshipTableName,\n )\n\n // Join in the relationships table\n if (locale && field.localized && adapter.payload.config.localization) {\n joinAliases.push({\n condition: and(\n eq((aliasTable || adapter.tables[rootTableName]).id, aliasRelationshipTable.parent),\n eq(aliasRelationshipTable.locale, locale),\n like(aliasRelationshipTable.path, `${constraintPath}${field.name}`),\n ),\n table: aliasRelationshipTable,\n })\n if (locale !== 'all') {\n constraints.push({\n columnName: 'locale',\n table: aliasRelationshipTable,\n value: locale,\n })\n }\n } else {\n // Join in the relationships table\n joinAliases.push({\n condition: and(\n eq((aliasTable || adapter.tables[rootTableName]).id, aliasRelationshipTable.parent),\n like(aliasRelationshipTable.path, `${constraintPath}${field.name}`),\n ),\n table: aliasRelationshipTable,\n })\n }\n\n selectFields[`${relationTableName}.path`] = aliasRelationshipTable.path\n\n let newAliasTable\n\n if (typeof field.relationTo === 'string') {\n const relationshipConfig = adapter.payload.collections[field.relationTo].config\n\n newTableName = adapter.tableNameMap.get(toSnakeCase(relationshipConfig.slug))\n\n // parent to relationship join table\n relationshipFields = relationshipConfig.fields\n\n newAliasTable = alias(adapter.tables[newTableName], toSnakeCase(uuid()))\n\n joinAliases.push({\n condition: eq(newAliasTable.id, aliasRelationshipTable[`${field.relationTo}ID`]),\n table: newAliasTable,\n })\n\n if (newCollectionPath === '' || newCollectionPath === 'id') {\n return {\n columnName: `${field.relationTo}ID`,\n constraints,\n field,\n table: aliasRelationshipTable,\n }\n }\n } else if (newCollectionPath === 'value') {\n const tableColumnsNames = field.relationTo.map((relationTo) => {\n const relationTableName = adapter.tableNameMap.get(\n toSnakeCase(adapter.payload.collections[relationTo].config.slug),\n )\n\n return `\"${aliasRelationshipTableName}\".\"${relationTableName}_id\"`\n })\n return {\n constraints,\n field,\n rawColumn: sql.raw(`COALESCE(${tableColumnsNames.join(', ')})`),\n table: aliasRelationshipTable,\n }\n } else if (newCollectionPath === 'relationTo') {\n const relationTo = Array.isArray(field.relationTo) ? field.relationTo : [field.relationTo]\n\n return {\n constraints,\n field,\n getNotNullColumnByValue: (val) => {\n const matchedRelation = relationTo.find((relation) => relation === val)\n if (matchedRelation) return `${matchedRelation}ID`\n return undefined\n },\n table: aliasRelationshipTable,\n }\n } else {\n throw new APIError('Not supported')\n }\n\n return getTableColumnFromPath({\n adapter,\n aliasTable: newAliasTable,\n collectionPath: newCollectionPath,\n constraints,\n fields: relationshipFields,\n joinAliases,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName: newTableName,\n selectFields,\n tableName: newTableName,\n value,\n })\n }\n }\n\n if (fieldAffectsData(field)) {\n if (field.localized && adapter.payload.config.localization) {\n // If localized, we go to localized table and set aliasTable to undefined\n // so it is not picked up below to be used as targetTable\n newTableName = `${tableName}${adapter.localesSuffix}`\n\n const parentTable = aliasTable || adapter.tables[tableName]\n\n joins[newTableName] = eq(parentTable.id, adapter.tables[newTableName]._parentID)\n\n aliasTable = undefined\n\n if (locale !== 'all') {\n constraints.push({\n columnName: '_locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n }\n\n const targetTable = aliasTable || adapter.tables[newTableName]\n\n selectFields[`${newTableName}.${columnPrefix}${field.name}`] =\n targetTable[`${columnPrefix}${field.name}`]\n\n return {\n columnName: `${columnPrefix}${field.name}`,\n constraints,\n field,\n pathSegments,\n table: targetTable,\n }\n }\n }\n\n throw new APIError(`Cannot find field for path at ${fieldPath}`)\n}\n"],"names":["and","eq","like","sql","alias","APIError","fieldAffectsData","tabHasName","flattenTopLevelFields","toSnakeCase","v4","uuid","getTableColumnFromPath","adapter","aliasTable","collectionPath","columnPrefix","constraintPath","incomingConstraintPath","constraints","fields","joinAliases","joins","locale","incomingLocale","pathSegments","incomingSegments","rootTableName","incomingRootTableName","selectFields","tableName","tableNameSuffix","value","fieldPath","field","find","fieldToFind","name","newTableName","id","tables","columnName","type","idType","table","localized","payload","config","localization","matchedLocale","localeCodes","splice","tabs","map","tab","slice","localesSuffix","_parentID","push","hasMany","tableNameMap","get","parent","_locale","tableType","joinConstraints","path","blockTableColumn","blockTypes","Array","isArray","forEach","blockType","block","blocks","slug","getNotNullColumnByValue","hasBlockField","some","result","blockConstraints","blockSelectFields","error","concat","rawColumn","relationshipFields","relationTableName","relationshipsSuffix","newCollectionPath","join","aliasRelationshipTableName","aliasRelationshipTable","condition","newAliasTable","relationTo","relationshipConfig","collections","tableColumnsNames","raw","val","matchedRelation","relation","undefined","parentTable","targetTable"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAczF,cAAcD,QAAQ2B,MAAM,CAACV,UAAU;gBAE3DR,KAAK,CAACgB,aAAa,GAAGrC,GAAGsG,YAAYhE,EAAE,EAAE1B,QAAQ2B,MAAM,CAACF,aAAa,CAACmB,SAAS;gBAE/E3C,aAAawF;gBAEb,IAAI/E,WAAW,OAAO;oBACpBJ,YAAYuC,IAAI,CAAC;wBACfjB,YAAY;wBACZG,OAAO/B,QAAQ2B,MAAM,CAACF,aAAa;wBACnCN,OAAOT;oBACT;gBACF;YACF;YAEA,MAAMiF,cAAc1F,cAAcD,QAAQ2B,MAAM,CAACF,aAAa;YAE9DT,YAAY,CAAC,CAAC,EAAES,aAAa,CAAC,EAAEtB,aAAa,EAAEkB,MAAMG,IAAI,CAAC,CAAC,CAAC,GAC1DmE,WAAW,CAAC,CAAC,EAAExF,aAAa,EAAEkB,MAAMG,IAAI,CAAC,CAAC,CAAC;YAE7C,OAAO;gBACLI,YAAY,CAAC,EAAEzB,aAAa,EAAEkB,MAAMG,IAAI,CAAC,CAAC;gBAC1ClB;gBACAe;gBACAT;gBACAmB,OAAO4D;YACT;QACF;IACF;IAEA,MAAM,IAAInG,SAAS,CAAC,8BAA8B,EAAE4B,UAAU,CAAC;AACjE,EAAC"}
1
+ {"version":3,"sources":["../../src/queries/getTableColumnFromPath.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { SQL } from 'drizzle-orm'\nimport type { PgTableWithColumns } from 'drizzle-orm/pg-core'\nimport type { Field, FieldAffectingData, NumberField, TabAsField, TextField } from 'payload/types'\n\nimport { and, eq, like, sql } from 'drizzle-orm'\nimport { alias } from 'drizzle-orm/pg-core'\nimport { APIError } from 'payload/errors'\nimport { fieldAffectsData, tabHasName } from 'payload/types'\nimport { flattenTopLevelFields } from 'payload/utilities'\nimport toSnakeCase from 'to-snake-case'\nimport { v4 as uuid } from 'uuid'\n\nimport type { GenericColumn, GenericTable, PostgresAdapter } from '../types.js'\nimport type { BuildQueryJoinAliases } from './buildQuery.js'\n\ntype Constraint = {\n columnName: string\n table: GenericTable | PgTableWithColumns<any>\n value: unknown\n}\n\ntype TableColumn = {\n columnName?: string\n constraints: Constraint[]\n field: FieldAffectingData\n getNotNullColumnByValue?: (val: unknown) => string\n pathSegments?: string[]\n rawColumn?: SQL\n table: GenericTable | PgTableWithColumns<any>\n}\n\ntype Args = {\n adapter: PostgresAdapter\n aliasTable?: GenericTable | PgTableWithColumns<any>\n collectionPath: string\n columnPrefix?: string\n constraintPath?: string\n constraints?: Constraint[]\n fields: (Field | TabAsField)[]\n joins: BuildQueryJoinAliases\n locale?: string\n pathSegments: string[]\n rootTableName?: string\n selectFields: Record<string, GenericColumn>\n tableName: string\n /**\n * If creating a new table name for arrays and blocks, this suffix should be appended to the table name\n */\n tableNameSuffix?: string\n /**\n * The raw value of the query before sanitization\n */\n value: unknown\n}\n/**\n * Transforms path to table and column name\n * Adds tables to `join`\n * @returns TableColumn\n */\nexport const getTableColumnFromPath = ({\n adapter,\n aliasTable,\n collectionPath,\n columnPrefix = '',\n constraintPath: incomingConstraintPath,\n constraints = [],\n fields,\n joins,\n locale: incomingLocale,\n pathSegments: incomingSegments,\n rootTableName: incomingRootTableName,\n selectFields,\n tableName,\n tableNameSuffix = '',\n value,\n}: Args): TableColumn => {\n const fieldPath = incomingSegments[0]\n let locale = incomingLocale\n const rootTableName = incomingRootTableName || tableName\n let constraintPath = incomingConstraintPath || ''\n\n const field = flattenTopLevelFields(fields as Field[]).find(\n (fieldToFind) => fieldAffectsData(fieldToFind) && fieldToFind.name === fieldPath,\n ) as Field | TabAsField\n let newTableName = tableName\n\n if (!field && fieldPath === 'id') {\n selectFields.id = adapter.tables[newTableName].id\n return {\n columnName: 'id',\n constraints,\n field: {\n name: 'id',\n type: adapter.idType === 'uuid' ? 'text' : 'number',\n } as NumberField | TextField,\n table: adapter.tables[newTableName],\n }\n }\n\n if (field) {\n const pathSegments = [...incomingSegments]\n\n // If next segment is a locale,\n // we need to take it out and use it as the locale from this point on\n if ('localized' in field && field.localized && adapter.payload.config.localization) {\n const matchedLocale = adapter.payload.config.localization.localeCodes.find(\n (locale) => locale === pathSegments[1],\n )\n\n if (matchedLocale) {\n locale = matchedLocale\n pathSegments.splice(1, 1)\n }\n }\n\n switch (field.type) {\n case 'tabs': {\n return getTableColumnFromPath({\n adapter,\n aliasTable,\n collectionPath,\n columnPrefix,\n constraintPath,\n constraints,\n fields: field.tabs.map((tab) => ({\n ...tab,\n type: 'tab',\n })),\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields,\n tableName: newTableName,\n tableNameSuffix,\n value,\n })\n }\n case 'tab': {\n if (tabHasName(field)) {\n return getTableColumnFromPath({\n adapter,\n aliasTable,\n collectionPath,\n columnPrefix: `${columnPrefix}${field.name}_`,\n constraintPath: `${constraintPath}${field.name}.`,\n constraints,\n fields: field.fields,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields,\n tableName: newTableName,\n tableNameSuffix: `${tableNameSuffix}${toSnakeCase(field.name)}_`,\n value,\n })\n }\n return getTableColumnFromPath({\n adapter,\n aliasTable,\n collectionPath,\n columnPrefix,\n constraintPath,\n constraints,\n fields: field.fields,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields,\n tableName: newTableName,\n tableNameSuffix,\n value,\n })\n }\n\n case 'group': {\n if (locale && field.localized && adapter.payload.config.localization) {\n newTableName = `${tableName}${adapter.localesSuffix}`\n\n joins.push({\n condition: eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID),\n table: adapter.tables[newTableName],\n })\n if (locale !== 'all') {\n constraints.push({\n columnName: '_locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n }\n return getTableColumnFromPath({\n adapter,\n aliasTable,\n collectionPath,\n columnPrefix: `${columnPrefix}${field.name}_`,\n constraintPath: `${constraintPath}${field.name}.`,\n constraints,\n fields: field.fields,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields,\n tableName: newTableName,\n tableNameSuffix: `${tableNameSuffix}${toSnakeCase(field.name)}_`,\n value,\n })\n }\n\n case 'select': {\n if (field.hasMany) {\n const newTableName = adapter.tableNameMap.get(\n `${tableName}_${tableNameSuffix}${toSnakeCase(field.name)}`,\n )\n\n if (locale && field.localized && adapter.payload.config.localization) {\n joins.push({\n condition: and(\n eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent),\n eq(adapter.tables[newTableName]._locale, locale),\n ),\n table: adapter.tables[newTableName],\n })\n if (locale !== 'all') {\n constraints.push({\n columnName: '_locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n } else {\n joins.push({\n condition: eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent),\n table: adapter.tables[newTableName],\n })\n }\n\n return {\n columnName: 'value',\n constraints,\n field,\n table: adapter.tables[newTableName],\n }\n }\n break\n }\n\n case 'text':\n case 'number': {\n if (field.hasMany) {\n let tableType = 'texts'\n let columnName = 'text'\n if (field.type === 'number') {\n tableType = 'numbers'\n columnName = 'number'\n }\n newTableName = `${tableName}_${tableType}`\n const joinConstraints = [\n eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent),\n eq(adapter.tables[newTableName].path, `${constraintPath}${field.name}`),\n ]\n\n if (locale && field.localized && adapter.payload.config.localization) {\n joins.push({\n condition: and(...joinConstraints, eq(adapter.tables[newTableName]._locale, locale)),\n table: adapter.tables[newTableName],\n })\n if (locale !== 'all') {\n constraints.push({\n columnName: 'locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n } else {\n joins.push({\n condition: and(...joinConstraints),\n table: adapter.tables[newTableName],\n })\n }\n\n return {\n columnName,\n constraints,\n field,\n table: adapter.tables[newTableName],\n }\n }\n break\n }\n\n case 'array': {\n newTableName = adapter.tableNameMap.get(\n `${tableName}_${tableNameSuffix}${toSnakeCase(field.name)}`,\n )\n\n constraintPath = `${constraintPath}${field.name}.%.`\n if (locale && field.localized && adapter.payload.config.localization) {\n joins.push({\n condition: and(\n eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID),\n eq(adapter.tables[newTableName]._locale, locale),\n ),\n table: adapter.tables[newTableName],\n })\n if (locale !== 'all') {\n constraints.push({\n columnName: '_locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n } else {\n joins.push({\n condition: eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID),\n table: adapter.tables[newTableName],\n })\n }\n return getTableColumnFromPath({\n adapter,\n collectionPath,\n constraintPath,\n constraints,\n fields: field.fields,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields,\n tableName: newTableName,\n value,\n })\n }\n\n case 'blocks': {\n let blockTableColumn: TableColumn\n let newTableName: string\n\n // handle blockType queries\n if (pathSegments[1] === 'blockType') {\n // find the block config using the value\n const blockTypes = Array.isArray(value) ? value : [value]\n blockTypes.forEach((blockType) => {\n const block = field.blocks.find((block) => block.slug === blockType)\n newTableName = adapter.tableNameMap.get(\n `${tableName}_blocks_${toSnakeCase(block.slug)}`,\n )\n const newAliasTableName = toSnakeCase(uuid())\n const newAliasTable = alias(adapter.tables[newTableName], newAliasTableName)\n\n joins.push({\n condition: eq(adapter.tables[tableName].id, newAliasTable._parentID),\n table: newAliasTable,\n })\n constraints.push({\n columnName: '_path',\n table: newAliasTable,\n value: pathSegments[0],\n })\n })\n return {\n constraints,\n field,\n getNotNullColumnByValue: () => 'id',\n table: adapter.tables[tableName],\n }\n }\n\n const hasBlockField = field.blocks.some((block) => {\n newTableName = adapter.tableNameMap.get(`${tableName}_blocks_${toSnakeCase(block.slug)}`)\n constraintPath = `${constraintPath}${field.name}.%.`\n\n let result\n const blockConstraints = []\n const blockSelectFields = {}\n try {\n result = getTableColumnFromPath({\n adapter,\n collectionPath,\n constraintPath,\n constraints: blockConstraints,\n fields: block.fields,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields: blockSelectFields,\n tableName: newTableName,\n value,\n })\n } catch (error) {\n // this is fine, not every block will have the field\n }\n if (!result) {\n return\n }\n blockTableColumn = result\n constraints = constraints.concat(blockConstraints)\n selectFields = { ...selectFields, ...blockSelectFields }\n if (field.localized && adapter.payload.config.localization) {\n joins.push({\n condition: and(\n eq(\n (aliasTable || adapter.tables[tableName]).id,\n adapter.tables[newTableName]._parentID,\n ),\n eq(adapter.tables[newTableName]._locale, locale),\n ),\n table: adapter.tables[newTableName],\n })\n if (locale) {\n constraints.push({\n columnName: '_locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n } else {\n joins.push({\n condition: eq(\n (aliasTable || adapter.tables[tableName]).id,\n adapter.tables[newTableName]._parentID,\n ),\n table: adapter.tables[newTableName],\n })\n }\n return true\n })\n if (hasBlockField) {\n return {\n columnName: blockTableColumn.columnName,\n constraints,\n field: blockTableColumn.field,\n pathSegments: pathSegments.slice(1),\n rawColumn: blockTableColumn.rawColumn,\n table: blockTableColumn.table,\n }\n }\n break\n }\n\n case 'relationship':\n case 'upload': {\n const newCollectionPath = pathSegments.slice(1).join('.')\n if (Array.isArray(field.relationTo) || (field.type === 'relationship' && field.hasMany)) {\n let relationshipFields\n const relationTableName = `${rootTableName}${adapter.relationshipsSuffix}`\n const aliasRelationshipTableName = uuid()\n const aliasRelationshipTable = alias(\n adapter.tables[relationTableName],\n aliasRelationshipTableName,\n )\n\n // Join in the relationships table\n if (locale && field.localized && adapter.payload.config.localization) {\n joins.push({\n condition: and(\n eq((aliasTable || adapter.tables[rootTableName]).id, aliasRelationshipTable.parent),\n eq(aliasRelationshipTable.locale, locale),\n like(aliasRelationshipTable.path, `${constraintPath}${field.name}`),\n ),\n table: aliasRelationshipTable,\n })\n if (locale !== 'all') {\n constraints.push({\n columnName: 'locale',\n table: aliasRelationshipTable,\n value: locale,\n })\n }\n } else {\n // Join in the relationships table\n joins.push({\n condition: and(\n eq((aliasTable || adapter.tables[rootTableName]).id, aliasRelationshipTable.parent),\n like(aliasRelationshipTable.path, `${constraintPath}${field.name}`),\n ),\n table: aliasRelationshipTable,\n })\n }\n\n selectFields[`${relationTableName}.path`] = aliasRelationshipTable.path\n\n let newAliasTable\n\n if (typeof field.relationTo === 'string') {\n const relationshipConfig = adapter.payload.collections[field.relationTo].config\n\n newTableName = adapter.tableNameMap.get(toSnakeCase(relationshipConfig.slug))\n\n // parent to relationship join table\n relationshipFields = relationshipConfig.fields\n\n newAliasTable = alias(adapter.tables[newTableName], toSnakeCase(uuid()))\n\n joins.push({\n condition: eq(newAliasTable.id, aliasRelationshipTable[`${field.relationTo}ID`]),\n table: newAliasTable,\n })\n\n if (newCollectionPath === '' || newCollectionPath === 'id') {\n return {\n columnName: `${field.relationTo}ID`,\n constraints,\n field,\n table: aliasRelationshipTable,\n }\n }\n } else if (newCollectionPath === 'value') {\n const tableColumnsNames = field.relationTo.map((relationTo) => {\n const relationTableName = adapter.tableNameMap.get(\n toSnakeCase(adapter.payload.collections[relationTo].config.slug),\n )\n\n return `\"${aliasRelationshipTableName}\".\"${relationTableName}_id\"`\n })\n return {\n constraints,\n field,\n rawColumn: sql.raw(`COALESCE(${tableColumnsNames.join(', ')})`),\n table: aliasRelationshipTable,\n }\n } else if (newCollectionPath === 'relationTo') {\n const relationTo = Array.isArray(field.relationTo)\n ? field.relationTo\n : [field.relationTo]\n\n return {\n constraints,\n field,\n getNotNullColumnByValue: (val) => {\n const matchedRelation = relationTo.find((relation) => relation === val)\n if (matchedRelation) return `${matchedRelation}ID`\n return undefined\n },\n table: aliasRelationshipTable,\n }\n } else {\n throw new APIError('Not supported')\n }\n\n return getTableColumnFromPath({\n adapter,\n aliasTable: newAliasTable,\n collectionPath: newCollectionPath,\n constraints,\n fields: relationshipFields,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName: newTableName,\n selectFields,\n tableName: newTableName,\n value,\n })\n } else if (\n pathSegments.length > 1 &&\n !(pathSegments.length === 2 && pathSegments[1] === 'id')\n ) {\n // simple relationships\n const columnName = `${columnPrefix}${field.name}`\n const newTableName = adapter.tableNameMap.get(\n toSnakeCase(adapter.payload.collections[field.relationTo].config.slug),\n )\n const aliasTableName = uuid()\n const newAliasTable = alias(adapter.tables[newTableName], aliasTableName)\n\n if (field.localized && adapter.payload.config.localization) {\n const aliasLocaleTableName = uuid()\n const aliasLocaleTable = alias(\n adapter.tables[`${rootTableName}${adapter.localesSuffix}`],\n aliasLocaleTableName,\n )\n joins.push({\n condition: and(\n eq(aliasLocaleTable._parentID, adapter.tables[rootTableName].id),\n eq(aliasLocaleTable._locale, locale),\n ),\n table: aliasLocaleTable,\n })\n joins.push({\n condition: eq(aliasLocaleTable[columnName], newAliasTable.id),\n table: newAliasTable,\n })\n } else {\n joins.push({\n condition: eq(\n newAliasTable.id,\n aliasTable ? aliasTable[columnName] : adapter.tables[tableName][columnName],\n ),\n table: newAliasTable,\n })\n }\n\n return getTableColumnFromPath({\n adapter,\n aliasTable: newAliasTable,\n collectionPath: newCollectionPath,\n constraintPath: '',\n constraints,\n fields: adapter.payload.collections[field.relationTo].config.fields,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n selectFields,\n tableName: newTableName,\n value,\n })\n }\n break\n }\n\n default: {\n // fall through\n break\n }\n }\n\n if (fieldAffectsData(field)) {\n if (field.localized && adapter.payload.config.localization) {\n // If localized, we go to localized table and set aliasTable to undefined\n // so it is not picked up below to be used as targetTable\n const parentTable = aliasTable || adapter.tables[tableName]\n newTableName = `${tableName}${adapter.localesSuffix}`\n\n joins.push({\n condition: eq(parentTable.id, adapter.tables[newTableName]._parentID),\n table: adapter.tables[newTableName],\n })\n\n aliasTable = undefined\n\n if (locale !== 'all') {\n constraints.push({\n columnName: '_locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n }\n\n const targetTable = aliasTable || adapter.tables[newTableName]\n\n selectFields[`${newTableName}.${columnPrefix}${field.name}`] =\n targetTable[`${columnPrefix}${field.name}`]\n\n return {\n columnName: `${columnPrefix}${field.name}`,\n constraints,\n field,\n pathSegments,\n table: targetTable,\n }\n }\n }\n\n throw new APIError(`Cannot find field for path at ${fieldPath}`)\n}\n"],"names":["and","eq","like","sql","alias","APIError","fieldAffectsData","tabHasName","flattenTopLevelFields","toSnakeCase","v4","uuid","getTableColumnFromPath","adapter","aliasTable","collectionPath","columnPrefix","constraintPath","incomingConstraintPath","constraints","fields","joins","locale","incomingLocale","pathSegments","incomingSegments","rootTableName","incomingRootTableName","selectFields","tableName","tableNameSuffix","value","fieldPath","field","find","fieldToFind","name","newTableName","id","tables","columnName","type","idType","table","localized","payload","config","localization","matchedLocale","localeCodes","splice","tabs","map","tab","slice","localesSuffix","push","condition","_parentID","hasMany","tableNameMap","get","parent","_locale","tableType","joinConstraints","path","blockTableColumn","blockTypes","Array","isArray","forEach","blockType","block","blocks","slug","newAliasTableName","newAliasTable","getNotNullColumnByValue","hasBlockField","some","result","blockConstraints","blockSelectFields","error","concat","rawColumn","newCollectionPath","join","relationTo","relationshipFields","relationTableName","relationshipsSuffix","aliasRelationshipTableName","aliasRelationshipTable","relationshipConfig","collections","tableColumnsNames","raw","val","matchedRelation","relation","undefined","length","aliasTableName","aliasLocaleTableName","aliasLocaleTable","parentTable","targetTable"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AMsF,cAAc9F,cAAcD,QAAQ0B,MAAM,CAACF,aAAa;YAE9DT,YAAY,CAAC,CAAC,EAAES,aAAa,CAAC,EAAErB,aAAa,EAAEiB,MAAMG,IAAI,CAAC,CAAC,CAAC,GAC1DwE,WAAW,CAAC,CAAC,EAAE5F,aAAa,EAAEiB,MAAMG,IAAI,CAAC,CAAC,CAAC;YAE7C,OAAO;gBACLI,YAAY,CAAC,EAAExB,aAAa,EAAEiB,MAAMG,IAAI,CAAC,CAAC;gBAC1CjB;gBACAc;gBACAT;gBACAmB,OAAOiE;YACT;QACF;IACF;IAEA,MAAM,IAAIvG,SAAS,CAAC,8BAA8B,EAAE2B,UAAU,CAAC;AACjE,EAAC"}
@@ -1,17 +1,16 @@
1
1
  import type { SQL } from 'drizzle-orm';
2
2
  import type { Field, Where } from 'payload/types';
3
3
  import type { GenericColumn, PostgresAdapter } from '../types.js';
4
- import type { BuildQueryJoinAliases, BuildQueryJoins } from './buildQuery.js';
4
+ import type { BuildQueryJoinAliases } from './buildQuery.js';
5
5
  type Args = {
6
6
  adapter: PostgresAdapter;
7
7
  fields: Field[];
8
- joinAliases: BuildQueryJoinAliases;
9
- joins: BuildQueryJoins;
8
+ joins: BuildQueryJoinAliases;
10
9
  locale: string;
11
10
  selectFields: Record<string, GenericColumn>;
12
11
  tableName: string;
13
12
  where: Where;
14
13
  };
15
- export declare function parseParams({ adapter, fields, joinAliases, joins, locale, selectFields, tableName, where, }: Args): Promise<SQL>;
14
+ export declare function parseParams({ adapter, fields, joins, locale, selectFields, tableName, where, }: Args): Promise<SQL>;
16
15
  export {};
17
16
  //# sourceMappingURL=parseParams.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseParams.d.ts","sourceRoot":"","sources":["../../src/queries/parseParams.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EAAE,KAAK,EAAY,KAAK,EAAE,MAAM,eAAe,CAAA;A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