@payloadcms/db-sqlite 3.0.0-canary.b8dd0db → 3.0.0-canary.c696728
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/connect.d.ts.map +1 -1
- package/dist/connect.js +10 -3
- package/dist/connect.js.map +1 -1
- package/dist/countDistinct.d.ts.map +1 -1
- package/dist/countDistinct.js +3 -3
- package/dist/countDistinct.js.map +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +13 -2
- package/dist/init.js.map +1 -1
- package/dist/schema/build.d.ts +11 -2
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/build.js +17 -8
- package/dist/schema/build.js.map +1 -1
- package/dist/schema/createIndex.d.ts.map +1 -1
- package/dist/schema/createIndex.js +3 -1
- package/dist/schema/createIndex.js.map +1 -1
- package/dist/schema/traverseFields.d.ts +7 -2
- package/dist/schema/traverseFields.d.ts.map +1 -1
- package/dist/schema/traverseFields.js +177 -59
- package/dist/schema/traverseFields.js.map +1 -1
- package/dist/schema/withDefault.d.ts.map +1 -1
- package/dist/schema/withDefault.js +3 -1
- package/dist/schema/withDefault.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +8 -6
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { createTableName, hasLocalesTable, validateExistingBlockIsIdentical } from '@payloadcms/drizzle';
|
|
2
2
|
import { relations } from 'drizzle-orm';
|
|
3
|
-
import {
|
|
3
|
+
import { foreignKey, index, integer, numeric, SQLiteIntegerBuilder, SQLiteNumericBuilder, SQLiteTextBuilder, text } from 'drizzle-orm/sqlite-core';
|
|
4
4
|
import { InvalidConfiguration } from 'payload';
|
|
5
|
-
import { fieldAffectsData, optionIsObject } from 'payload/shared';
|
|
5
|
+
import { fieldAffectsData, fieldIsVirtual, optionIsObject } from 'payload/shared';
|
|
6
6
|
import toSnakeCase from 'to-snake-case';
|
|
7
7
|
import { buildTable } from './build.js';
|
|
8
8
|
import { createIndex } from './createIndex.js';
|
|
9
9
|
import { getIDColumn } from './getIDColumn.js';
|
|
10
10
|
import { idToUUID } from './idToUUID.js';
|
|
11
11
|
import { withDefault } from './withDefault.js';
|
|
12
|
-
export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull, disableUnique = false, fieldPrefix, fields, forceLocalized, indexes, locales, localesColumns, localesIndexes, newTableName, parentTableName,
|
|
12
|
+
export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull, disableUnique = false, fieldPrefix, fields, forceLocalized, indexes, locales, localesColumns, localesIndexes, newTableName, parentTableName, relationships, relationsToBuild, rootRelationsToBuild, rootTableIDColType, rootTableName, versions, withinLocalizedArrayOrBlock })=>{
|
|
13
13
|
let hasLocalizedField = false;
|
|
14
14
|
let hasLocalizedRelationshipField = false;
|
|
15
15
|
let hasManyTextField = false;
|
|
@@ -17,11 +17,22 @@ export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull,
|
|
|
17
17
|
let hasManyNumberField = false;
|
|
18
18
|
let hasLocalizedManyNumberField = false;
|
|
19
19
|
let parentIDColType = 'integer';
|
|
20
|
-
if (columns.id instanceof SQLiteIntegerBuilder)
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
if (columns.id instanceof SQLiteIntegerBuilder) {
|
|
21
|
+
parentIDColType = 'integer';
|
|
22
|
+
}
|
|
23
|
+
if (columns.id instanceof SQLiteNumericBuilder) {
|
|
24
|
+
parentIDColType = 'numeric';
|
|
25
|
+
}
|
|
26
|
+
if (columns.id instanceof SQLiteTextBuilder) {
|
|
27
|
+
parentIDColType = 'text';
|
|
28
|
+
}
|
|
23
29
|
fields.forEach((field)=>{
|
|
24
|
-
if ('name' in field && field.name === 'id')
|
|
30
|
+
if ('name' in field && field.name === 'id') {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (fieldIsVirtual(field)) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
25
36
|
let columnName;
|
|
26
37
|
let fieldName;
|
|
27
38
|
let targetTable = columns;
|
|
@@ -53,7 +64,10 @@ export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull,
|
|
|
53
64
|
adapter.fieldConstraints[rootTableName][`${columnName}_idx`] = constraintValue;
|
|
54
65
|
}
|
|
55
66
|
targetIndexes[`${newTableName}_${field.name}Idx`] = createIndex({
|
|
56
|
-
name:
|
|
67
|
+
name: field.localized ? [
|
|
68
|
+
fieldName,
|
|
69
|
+
'_locale'
|
|
70
|
+
] : fieldName,
|
|
57
71
|
columnName,
|
|
58
72
|
tableName: newTableName,
|
|
59
73
|
unique
|
|
@@ -64,7 +78,8 @@ export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull,
|
|
|
64
78
|
case 'text':
|
|
65
79
|
{
|
|
66
80
|
if (field.hasMany) {
|
|
67
|
-
|
|
81
|
+
const isLocalized = Boolean(field.localized && adapter.payload.config.localization) || withinLocalizedArrayOrBlock || forceLocalized;
|
|
82
|
+
if (isLocalized) {
|
|
68
83
|
hasLocalizedManyTextField = true;
|
|
69
84
|
}
|
|
70
85
|
if (field.index) {
|
|
@@ -90,7 +105,8 @@ export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull,
|
|
|
90
105
|
case 'number':
|
|
91
106
|
{
|
|
92
107
|
if (field.hasMany) {
|
|
93
|
-
|
|
108
|
+
const isLocalized = Boolean(field.localized && adapter.payload.config.localization) || withinLocalizedArrayOrBlock || forceLocalized;
|
|
109
|
+
if (isLocalized) {
|
|
94
110
|
hasLocalizedManyNumberField = true;
|
|
95
111
|
}
|
|
96
112
|
if (field.index) {
|
|
@@ -165,7 +181,8 @@ export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull,
|
|
|
165
181
|
}).onDelete('cascade'),
|
|
166
182
|
parentIdx: (cols)=>index(`${selectTableName}_parent_idx`).on(cols.parent)
|
|
167
183
|
};
|
|
168
|
-
|
|
184
|
+
const isLocalized = Boolean(field.localized && adapter.payload.config.localization) || withinLocalizedArrayOrBlock || forceLocalized;
|
|
185
|
+
if (isLocalized) {
|
|
169
186
|
baseColumns.locale = text('locale', {
|
|
170
187
|
enum: locales
|
|
171
188
|
}).notNull();
|
|
@@ -248,31 +265,46 @@ export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull,
|
|
|
248
265
|
}).onDelete('cascade'),
|
|
249
266
|
_parentIDIdx: (cols)=>index(`${arrayTableName}_parent_id_idx`).on(cols._parentID)
|
|
250
267
|
};
|
|
251
|
-
|
|
268
|
+
const isLocalized = Boolean(field.localized && adapter.payload.config.localization) || withinLocalizedArrayOrBlock || forceLocalized;
|
|
269
|
+
if (isLocalized) {
|
|
252
270
|
baseColumns._locale = text('_locale', {
|
|
253
271
|
enum: locales
|
|
254
272
|
}).notNull();
|
|
255
273
|
baseExtraConfig._localeIdx = (cols)=>index(`${arrayTableName}_locale_idx`).on(cols._locale);
|
|
256
274
|
}
|
|
257
|
-
const { hasManyNumberField: subHasManyNumberField, hasManyTextField: subHasManyTextField, relationsToBuild: subRelationsToBuild } = buildTable({
|
|
275
|
+
const { hasLocalizedManyNumberField: subHasLocalizedManyNumberField, hasLocalizedManyTextField: subHasLocalizedManyTextField, hasLocalizedRelationshipField: subHasLocalizedRelationshipField, hasManyNumberField: subHasManyNumberField, hasManyTextField: subHasManyTextField, relationsToBuild: subRelationsToBuild } = buildTable({
|
|
258
276
|
adapter,
|
|
259
277
|
baseColumns,
|
|
260
278
|
baseExtraConfig,
|
|
261
279
|
disableNotNull: disableNotNullFromHere,
|
|
262
280
|
disableUnique,
|
|
263
281
|
fields: disableUnique ? idToUUID(field.fields) : field.fields,
|
|
264
|
-
rootRelationsToBuild,
|
|
265
282
|
rootRelationships: relationships,
|
|
283
|
+
rootRelationsToBuild,
|
|
266
284
|
rootTableIDColType,
|
|
267
285
|
rootTableName,
|
|
268
286
|
tableName: arrayTableName,
|
|
269
|
-
versions
|
|
287
|
+
versions,
|
|
288
|
+
withinLocalizedArrayOrBlock: isLocalized
|
|
270
289
|
});
|
|
290
|
+
if (subHasLocalizedManyNumberField) {
|
|
291
|
+
hasLocalizedManyNumberField = subHasLocalizedManyNumberField;
|
|
292
|
+
}
|
|
293
|
+
if (subHasLocalizedRelationshipField) {
|
|
294
|
+
hasLocalizedRelationshipField = subHasLocalizedRelationshipField;
|
|
295
|
+
}
|
|
296
|
+
if (subHasLocalizedManyTextField) {
|
|
297
|
+
hasLocalizedManyTextField = subHasLocalizedManyTextField;
|
|
298
|
+
}
|
|
271
299
|
if (subHasManyTextField) {
|
|
272
|
-
if (!hasManyTextField || subHasManyTextField === 'index')
|
|
300
|
+
if (!hasManyTextField || subHasManyTextField === 'index') {
|
|
301
|
+
hasManyTextField = subHasManyTextField;
|
|
302
|
+
}
|
|
273
303
|
}
|
|
274
304
|
if (subHasManyNumberField) {
|
|
275
|
-
if (!hasManyNumberField || subHasManyNumberField === 'index')
|
|
305
|
+
if (!hasManyNumberField || subHasManyNumberField === 'index') {
|
|
306
|
+
hasManyNumberField = subHasManyNumberField;
|
|
307
|
+
}
|
|
276
308
|
}
|
|
277
309
|
relationsToBuild.set(fieldName, {
|
|
278
310
|
type: 'many',
|
|
@@ -344,7 +376,6 @@ export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull,
|
|
|
344
376
|
};
|
|
345
377
|
const baseExtraConfig = {
|
|
346
378
|
_orderIdx: (cols)=>index(`${blockTableName}_order_idx`).on(cols._order),
|
|
347
|
-
_parentIDIdx: (cols)=>index(`${blockTableName}_parent_id_idx`).on(cols._parentID),
|
|
348
379
|
_parentIdFk: (cols)=>foreignKey({
|
|
349
380
|
name: `${blockTableName}_parent_id_fk`,
|
|
350
381
|
columns: [
|
|
@@ -354,33 +385,49 @@ export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull,
|
|
|
354
385
|
adapter.tables[rootTableName].id
|
|
355
386
|
]
|
|
356
387
|
}).onDelete('cascade'),
|
|
388
|
+
_parentIDIdx: (cols)=>index(`${blockTableName}_parent_id_idx`).on(cols._parentID),
|
|
357
389
|
_pathIdx: (cols)=>index(`${blockTableName}_path_idx`).on(cols._path)
|
|
358
390
|
};
|
|
359
|
-
|
|
391
|
+
const isLocalized = Boolean(field.localized && adapter.payload.config.localization) || withinLocalizedArrayOrBlock || forceLocalized;
|
|
392
|
+
if (isLocalized) {
|
|
360
393
|
baseColumns._locale = text('_locale', {
|
|
361
394
|
enum: locales
|
|
362
395
|
}).notNull();
|
|
363
396
|
baseExtraConfig._localeIdx = (cols)=>index(`${blockTableName}_locale_idx`).on(cols._locale);
|
|
364
397
|
}
|
|
365
|
-
const { hasManyNumberField: subHasManyNumberField, hasManyTextField: subHasManyTextField, relationsToBuild: subRelationsToBuild } = buildTable({
|
|
398
|
+
const { hasLocalizedManyNumberField: subHasLocalizedManyNumberField, hasLocalizedManyTextField: subHasLocalizedManyTextField, hasLocalizedRelationshipField: subHasLocalizedRelationshipField, hasManyNumberField: subHasManyNumberField, hasManyTextField: subHasManyTextField, relationsToBuild: subRelationsToBuild } = buildTable({
|
|
366
399
|
adapter,
|
|
367
400
|
baseColumns,
|
|
368
401
|
baseExtraConfig,
|
|
369
402
|
disableNotNull: disableNotNullFromHere,
|
|
370
403
|
disableUnique,
|
|
371
404
|
fields: disableUnique ? idToUUID(block.fields) : block.fields,
|
|
372
|
-
rootRelationsToBuild,
|
|
373
405
|
rootRelationships: relationships,
|
|
406
|
+
rootRelationsToBuild,
|
|
374
407
|
rootTableIDColType,
|
|
375
408
|
rootTableName,
|
|
376
409
|
tableName: blockTableName,
|
|
377
|
-
versions
|
|
410
|
+
versions,
|
|
411
|
+
withinLocalizedArrayOrBlock: isLocalized
|
|
378
412
|
});
|
|
413
|
+
if (subHasLocalizedManyNumberField) {
|
|
414
|
+
hasLocalizedManyNumberField = subHasLocalizedManyNumberField;
|
|
415
|
+
}
|
|
416
|
+
if (subHasLocalizedRelationshipField) {
|
|
417
|
+
hasLocalizedRelationshipField = subHasLocalizedRelationshipField;
|
|
418
|
+
}
|
|
419
|
+
if (subHasLocalizedManyTextField) {
|
|
420
|
+
hasLocalizedManyTextField = subHasLocalizedManyTextField;
|
|
421
|
+
}
|
|
379
422
|
if (subHasManyTextField) {
|
|
380
|
-
if (!hasManyTextField || subHasManyTextField === 'index')
|
|
423
|
+
if (!hasManyTextField || subHasManyTextField === 'index') {
|
|
424
|
+
hasManyTextField = subHasManyTextField;
|
|
425
|
+
}
|
|
381
426
|
}
|
|
382
427
|
if (subHasManyNumberField) {
|
|
383
|
-
if (!hasManyNumberField || subHasManyNumberField === 'index')
|
|
428
|
+
if (!hasManyNumberField || subHasManyNumberField === 'index') {
|
|
429
|
+
hasManyNumberField = subHasManyNumberField;
|
|
430
|
+
}
|
|
384
431
|
}
|
|
385
432
|
adapter.relations[`relations_${blockTableName}`] = relations(adapter.tables[blockTableName], ({ many, one })=>{
|
|
386
433
|
const result = {
|
|
@@ -458,19 +505,32 @@ export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull,
|
|
|
458
505
|
localesIndexes,
|
|
459
506
|
newTableName,
|
|
460
507
|
parentTableName,
|
|
461
|
-
relationsToBuild,
|
|
462
508
|
relationships,
|
|
509
|
+
relationsToBuild,
|
|
463
510
|
rootRelationsToBuild,
|
|
464
511
|
rootTableIDColType,
|
|
465
512
|
rootTableName,
|
|
466
|
-
versions
|
|
513
|
+
versions,
|
|
514
|
+
withinLocalizedArrayOrBlock
|
|
467
515
|
});
|
|
468
|
-
if (groupHasLocalizedField)
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
if (
|
|
472
|
-
|
|
473
|
-
|
|
516
|
+
if (groupHasLocalizedField) {
|
|
517
|
+
hasLocalizedField = true;
|
|
518
|
+
}
|
|
519
|
+
if (groupHasLocalizedRelationshipField) {
|
|
520
|
+
hasLocalizedRelationshipField = true;
|
|
521
|
+
}
|
|
522
|
+
if (groupHasManyTextField) {
|
|
523
|
+
hasManyTextField = true;
|
|
524
|
+
}
|
|
525
|
+
if (groupHasLocalizedManyTextField) {
|
|
526
|
+
hasLocalizedManyTextField = true;
|
|
527
|
+
}
|
|
528
|
+
if (groupHasManyNumberField) {
|
|
529
|
+
hasManyNumberField = true;
|
|
530
|
+
}
|
|
531
|
+
if (groupHasLocalizedManyNumberField) {
|
|
532
|
+
hasLocalizedManyNumberField = true;
|
|
533
|
+
}
|
|
474
534
|
break;
|
|
475
535
|
}
|
|
476
536
|
const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull;
|
|
@@ -489,19 +549,32 @@ export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull,
|
|
|
489
549
|
localesIndexes,
|
|
490
550
|
newTableName: `${parentTableName}_${columnName}`,
|
|
491
551
|
parentTableName,
|
|
492
|
-
relationsToBuild,
|
|
493
552
|
relationships,
|
|
553
|
+
relationsToBuild,
|
|
494
554
|
rootRelationsToBuild,
|
|
495
555
|
rootTableIDColType,
|
|
496
556
|
rootTableName,
|
|
497
|
-
versions
|
|
557
|
+
versions,
|
|
558
|
+
withinLocalizedArrayOrBlock
|
|
498
559
|
});
|
|
499
|
-
if (groupHasLocalizedField)
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
if (
|
|
503
|
-
|
|
504
|
-
|
|
560
|
+
if (groupHasLocalizedField) {
|
|
561
|
+
hasLocalizedField = true;
|
|
562
|
+
}
|
|
563
|
+
if (groupHasLocalizedRelationshipField) {
|
|
564
|
+
hasLocalizedRelationshipField = true;
|
|
565
|
+
}
|
|
566
|
+
if (groupHasManyTextField) {
|
|
567
|
+
hasManyTextField = true;
|
|
568
|
+
}
|
|
569
|
+
if (groupHasLocalizedManyTextField) {
|
|
570
|
+
hasLocalizedManyTextField = true;
|
|
571
|
+
}
|
|
572
|
+
if (groupHasManyNumberField) {
|
|
573
|
+
hasManyNumberField = true;
|
|
574
|
+
}
|
|
575
|
+
if (groupHasLocalizedManyNumberField) {
|
|
576
|
+
hasLocalizedManyNumberField = true;
|
|
577
|
+
}
|
|
505
578
|
break;
|
|
506
579
|
}
|
|
507
580
|
case 'tabs':
|
|
@@ -525,19 +598,32 @@ export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull,
|
|
|
525
598
|
localesIndexes,
|
|
526
599
|
newTableName,
|
|
527
600
|
parentTableName,
|
|
528
|
-
relationsToBuild,
|
|
529
601
|
relationships,
|
|
602
|
+
relationsToBuild,
|
|
530
603
|
rootRelationsToBuild,
|
|
531
604
|
rootTableIDColType,
|
|
532
605
|
rootTableName,
|
|
533
|
-
versions
|
|
606
|
+
versions,
|
|
607
|
+
withinLocalizedArrayOrBlock
|
|
534
608
|
});
|
|
535
|
-
if (tabHasLocalizedField)
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
if (
|
|
539
|
-
|
|
540
|
-
|
|
609
|
+
if (tabHasLocalizedField) {
|
|
610
|
+
hasLocalizedField = true;
|
|
611
|
+
}
|
|
612
|
+
if (tabHasLocalizedRelationshipField) {
|
|
613
|
+
hasLocalizedRelationshipField = true;
|
|
614
|
+
}
|
|
615
|
+
if (tabHasManyTextField) {
|
|
616
|
+
hasManyTextField = true;
|
|
617
|
+
}
|
|
618
|
+
if (tabHasLocalizedManyTextField) {
|
|
619
|
+
hasLocalizedManyTextField = true;
|
|
620
|
+
}
|
|
621
|
+
if (tabHasManyNumberField) {
|
|
622
|
+
hasManyNumberField = true;
|
|
623
|
+
}
|
|
624
|
+
if (tabHasLocalizedManyNumberField) {
|
|
625
|
+
hasLocalizedManyNumberField = true;
|
|
626
|
+
}
|
|
541
627
|
break;
|
|
542
628
|
}
|
|
543
629
|
case 'row':
|
|
@@ -559,19 +645,32 @@ export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull,
|
|
|
559
645
|
localesIndexes,
|
|
560
646
|
newTableName,
|
|
561
647
|
parentTableName,
|
|
562
|
-
relationsToBuild,
|
|
563
648
|
relationships,
|
|
649
|
+
relationsToBuild,
|
|
564
650
|
rootRelationsToBuild,
|
|
565
651
|
rootTableIDColType,
|
|
566
652
|
rootTableName,
|
|
567
|
-
versions
|
|
653
|
+
versions,
|
|
654
|
+
withinLocalizedArrayOrBlock
|
|
568
655
|
});
|
|
569
|
-
if (rowHasLocalizedField)
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
if (
|
|
573
|
-
|
|
574
|
-
|
|
656
|
+
if (rowHasLocalizedField) {
|
|
657
|
+
hasLocalizedField = true;
|
|
658
|
+
}
|
|
659
|
+
if (rowHasLocalizedRelationshipField) {
|
|
660
|
+
hasLocalizedRelationshipField = true;
|
|
661
|
+
}
|
|
662
|
+
if (rowHasManyTextField) {
|
|
663
|
+
hasManyTextField = true;
|
|
664
|
+
}
|
|
665
|
+
if (rowHasLocalizedManyTextField) {
|
|
666
|
+
hasLocalizedManyTextField = true;
|
|
667
|
+
}
|
|
668
|
+
if (rowHasManyNumberField) {
|
|
669
|
+
hasManyNumberField = true;
|
|
670
|
+
}
|
|
671
|
+
if (rowHasLocalizedManyNumberField) {
|
|
672
|
+
hasLocalizedManyNumberField = true;
|
|
673
|
+
}
|
|
575
674
|
break;
|
|
576
675
|
}
|
|
577
676
|
case 'relationship':
|
|
@@ -587,8 +686,12 @@ export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull,
|
|
|
587
686
|
// get the id type of the related collection
|
|
588
687
|
let colType = 'integer';
|
|
589
688
|
const relatedCollectionCustomID = relationshipConfig.fields.find((field)=>fieldAffectsData(field) && field.name === 'id');
|
|
590
|
-
if (relatedCollectionCustomID?.type === 'number')
|
|
591
|
-
|
|
689
|
+
if (relatedCollectionCustomID?.type === 'number') {
|
|
690
|
+
colType = 'numeric';
|
|
691
|
+
}
|
|
692
|
+
if (relatedCollectionCustomID?.type === 'text') {
|
|
693
|
+
colType = 'text';
|
|
694
|
+
}
|
|
592
695
|
// make the foreign key column for relationship using the correct id column type
|
|
593
696
|
targetTable[fieldName] = getIDColumn({
|
|
594
697
|
name: `${columnName}_id`,
|
|
@@ -609,10 +712,25 @@ export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull,
|
|
|
609
712
|
}
|
|
610
713
|
break;
|
|
611
714
|
}
|
|
612
|
-
if (adapter.payload.config.localization
|
|
715
|
+
if (Boolean(field.localized && adapter.payload.config.localization) || withinLocalizedArrayOrBlock) {
|
|
613
716
|
hasLocalizedRelationshipField = true;
|
|
614
717
|
}
|
|
615
718
|
break;
|
|
719
|
+
case 'join':
|
|
720
|
+
{
|
|
721
|
+
// fieldName could be 'posts' or 'group_posts'
|
|
722
|
+
// using on as the key for the relation
|
|
723
|
+
const localized = adapter.payload.config.localization && field.localized;
|
|
724
|
+
const target = `${adapter.tableNameMap.get(toSnakeCase(field.collection))}${localized ? adapter.localesSuffix : ''}`;
|
|
725
|
+
relationsToBuild.set(fieldName, {
|
|
726
|
+
type: 'many',
|
|
727
|
+
// joins are not localized on the parent table
|
|
728
|
+
localized: false,
|
|
729
|
+
relationName: toSnakeCase(field.on),
|
|
730
|
+
target
|
|
731
|
+
});
|
|
732
|
+
break;
|
|
733
|
+
}
|
|
616
734
|
default:
|
|
617
735
|
break;
|
|
618
736
|
}
|