@payloadcms/db-sqlite 3.0.0-canary.51be7be → 3.0.0-canary.5624723
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.map +1 -1
- package/dist/countDistinct.d.ts.map +1 -1
- package/dist/countDistinct.js +2 -3
- package/dist/countDistinct.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +0 -1
- package/dist/init.js.map +1 -1
- package/dist/schema/build.d.ts +2 -3
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/build.js +1 -2
- package/dist/schema/build.js.map +1 -1
- package/dist/schema/traverseFields.d.ts +2 -3
- package/dist/schema/traverseFields.d.ts.map +1 -1
- package/dist/schema/traverseFields.js +244 -270
- package/dist/schema/traverseFields.js.map +1 -1
- package/license.md +22 -0
- package/package.json +15 -8
|
@@ -9,7 +9,7 @@ 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, disableRelsTableUnique, disableUnique = false, fieldPrefix, fields, forceLocalized, indexes,
|
|
12
|
+
export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull, disableRelsTableUnique, disableUnique = false, fieldPrefix, fields, forceLocalized, indexes, locales, localesColumns, localesIndexes, newTableName, parentTableName, relationships, relationsToBuild, rootRelationsToBuild, rootTableIDColType, rootTableName, uniqueRelationships, versions, withinLocalizedArrayOrBlock })=>{
|
|
13
13
|
let hasLocalizedField = false;
|
|
14
14
|
let hasLocalizedRelationshipField = false;
|
|
15
15
|
let hasManyTextField = false;
|
|
@@ -79,164 +79,6 @@ export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull,
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
switch(field.type){
|
|
82
|
-
case 'text':
|
|
83
|
-
{
|
|
84
|
-
if (field.hasMany) {
|
|
85
|
-
const isLocalized = Boolean(field.localized && adapter.payload.config.localization) || withinLocalizedArrayOrBlock || forceLocalized;
|
|
86
|
-
if (isLocalized) {
|
|
87
|
-
hasLocalizedManyTextField = true;
|
|
88
|
-
}
|
|
89
|
-
if (field.index) {
|
|
90
|
-
hasManyTextField = 'index';
|
|
91
|
-
} else if (!hasManyTextField) {
|
|
92
|
-
hasManyTextField = true;
|
|
93
|
-
}
|
|
94
|
-
if (field.unique) {
|
|
95
|
-
throw new InvalidConfiguration('Unique is not supported in SQLite for hasMany text fields.');
|
|
96
|
-
}
|
|
97
|
-
} else {
|
|
98
|
-
targetTable[fieldName] = withDefault(text(columnName), field);
|
|
99
|
-
}
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
case 'email':
|
|
103
|
-
case 'code':
|
|
104
|
-
case 'textarea':
|
|
105
|
-
{
|
|
106
|
-
targetTable[fieldName] = withDefault(text(columnName), field);
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
case 'number':
|
|
110
|
-
{
|
|
111
|
-
if (field.hasMany) {
|
|
112
|
-
const isLocalized = Boolean(field.localized && adapter.payload.config.localization) || withinLocalizedArrayOrBlock || forceLocalized;
|
|
113
|
-
if (isLocalized) {
|
|
114
|
-
hasLocalizedManyNumberField = true;
|
|
115
|
-
}
|
|
116
|
-
if (field.index) {
|
|
117
|
-
hasManyNumberField = 'index';
|
|
118
|
-
} else if (!hasManyNumberField) {
|
|
119
|
-
hasManyNumberField = true;
|
|
120
|
-
}
|
|
121
|
-
if (field.unique) {
|
|
122
|
-
throw new InvalidConfiguration('Unique is not supported in Postgres for hasMany number fields.');
|
|
123
|
-
}
|
|
124
|
-
} else {
|
|
125
|
-
targetTable[fieldName] = withDefault(numeric(columnName), field);
|
|
126
|
-
}
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
case 'richText':
|
|
130
|
-
case 'json':
|
|
131
|
-
{
|
|
132
|
-
targetTable[fieldName] = withDefault(text(columnName, {
|
|
133
|
-
mode: 'json'
|
|
134
|
-
}), field);
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
case 'date':
|
|
138
|
-
{
|
|
139
|
-
targetTable[fieldName] = withDefault(text(columnName), field);
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
142
|
-
case 'point':
|
|
143
|
-
{
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
case 'radio':
|
|
147
|
-
case 'select':
|
|
148
|
-
{
|
|
149
|
-
const options = field.options.map((option)=>{
|
|
150
|
-
if (optionIsObject(option)) {
|
|
151
|
-
return option.value;
|
|
152
|
-
}
|
|
153
|
-
return option;
|
|
154
|
-
});
|
|
155
|
-
if (field.type === 'select' && field.hasMany) {
|
|
156
|
-
const selectTableName = createTableName({
|
|
157
|
-
adapter,
|
|
158
|
-
config: field,
|
|
159
|
-
parentTableName: newTableName,
|
|
160
|
-
prefix: `${newTableName}_`,
|
|
161
|
-
versionsCustomName: versions
|
|
162
|
-
});
|
|
163
|
-
const baseColumns = {
|
|
164
|
-
order: integer('order').notNull(),
|
|
165
|
-
parent: getIDColumn({
|
|
166
|
-
name: 'parent_id',
|
|
167
|
-
type: parentIDColType,
|
|
168
|
-
notNull: true,
|
|
169
|
-
primaryKey: false
|
|
170
|
-
}),
|
|
171
|
-
value: text('value', {
|
|
172
|
-
enum: options
|
|
173
|
-
})
|
|
174
|
-
};
|
|
175
|
-
const baseExtraConfig = {
|
|
176
|
-
orderIdx: (cols)=>index(`${selectTableName}_order_idx`).on(cols.order),
|
|
177
|
-
parentFk: (cols)=>foreignKey({
|
|
178
|
-
name: `${selectTableName}_parent_fk`,
|
|
179
|
-
columns: [
|
|
180
|
-
cols.parent
|
|
181
|
-
],
|
|
182
|
-
foreignColumns: [
|
|
183
|
-
adapter.tables[parentTableName].id
|
|
184
|
-
]
|
|
185
|
-
}).onDelete('cascade'),
|
|
186
|
-
parentIdx: (cols)=>index(`${selectTableName}_parent_idx`).on(cols.parent)
|
|
187
|
-
};
|
|
188
|
-
const isLocalized = Boolean(field.localized && adapter.payload.config.localization) || withinLocalizedArrayOrBlock || forceLocalized;
|
|
189
|
-
if (isLocalized) {
|
|
190
|
-
baseColumns.locale = text('locale', {
|
|
191
|
-
enum: locales
|
|
192
|
-
}).notNull();
|
|
193
|
-
baseExtraConfig.localeIdx = (cols)=>index(`${selectTableName}_locale_idx`).on(cols.locale);
|
|
194
|
-
}
|
|
195
|
-
if (field.index) {
|
|
196
|
-
baseExtraConfig.value = (cols)=>index(`${selectTableName}_value_idx`).on(cols.value);
|
|
197
|
-
}
|
|
198
|
-
buildTable({
|
|
199
|
-
adapter,
|
|
200
|
-
baseColumns,
|
|
201
|
-
baseExtraConfig,
|
|
202
|
-
disableNotNull,
|
|
203
|
-
disableUnique,
|
|
204
|
-
fields: [],
|
|
205
|
-
rootTableName,
|
|
206
|
-
tableName: selectTableName,
|
|
207
|
-
versions
|
|
208
|
-
});
|
|
209
|
-
relationsToBuild.set(fieldName, {
|
|
210
|
-
type: 'many',
|
|
211
|
-
// selects have their own localized table, independent of the base table.
|
|
212
|
-
localized: false,
|
|
213
|
-
target: selectTableName
|
|
214
|
-
});
|
|
215
|
-
adapter.relations[`relations_${selectTableName}`] = relations(adapter.tables[selectTableName], ({ one })=>({
|
|
216
|
-
parent: one(adapter.tables[parentTableName], {
|
|
217
|
-
fields: [
|
|
218
|
-
adapter.tables[selectTableName].parent
|
|
219
|
-
],
|
|
220
|
-
references: [
|
|
221
|
-
adapter.tables[parentTableName].id
|
|
222
|
-
],
|
|
223
|
-
relationName: fieldName
|
|
224
|
-
})
|
|
225
|
-
}));
|
|
226
|
-
} else {
|
|
227
|
-
targetTable[fieldName] = withDefault(text(columnName, {
|
|
228
|
-
enum: options
|
|
229
|
-
}), field);
|
|
230
|
-
}
|
|
231
|
-
break;
|
|
232
|
-
}
|
|
233
|
-
case 'checkbox':
|
|
234
|
-
{
|
|
235
|
-
targetTable[fieldName] = withDefault(integer(columnName, {
|
|
236
|
-
mode: 'boolean'
|
|
237
|
-
}), field);
|
|
238
|
-
break;
|
|
239
|
-
}
|
|
240
82
|
case 'array':
|
|
241
83
|
{
|
|
242
84
|
const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull;
|
|
@@ -494,8 +336,75 @@ export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull,
|
|
|
494
336
|
});
|
|
495
337
|
break;
|
|
496
338
|
}
|
|
497
|
-
case '
|
|
339
|
+
case 'checkbox':
|
|
340
|
+
{
|
|
341
|
+
targetTable[fieldName] = withDefault(integer(columnName, {
|
|
342
|
+
mode: 'boolean'
|
|
343
|
+
}), field);
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
case 'code':
|
|
347
|
+
case 'email':
|
|
348
|
+
case 'textarea':
|
|
349
|
+
{
|
|
350
|
+
targetTable[fieldName] = withDefault(text(columnName), field);
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
case 'collapsible':
|
|
354
|
+
case 'row':
|
|
355
|
+
{
|
|
356
|
+
const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull;
|
|
357
|
+
const { hasLocalizedField: rowHasLocalizedField, hasLocalizedManyNumberField: rowHasLocalizedManyNumberField, hasLocalizedManyTextField: rowHasLocalizedManyTextField, hasLocalizedRelationshipField: rowHasLocalizedRelationshipField, hasManyNumberField: rowHasManyNumberField, hasManyTextField: rowHasManyTextField } = traverseFields({
|
|
358
|
+
adapter,
|
|
359
|
+
columnPrefix,
|
|
360
|
+
columns,
|
|
361
|
+
disableNotNull: disableNotNullFromHere,
|
|
362
|
+
disableUnique,
|
|
363
|
+
fieldPrefix,
|
|
364
|
+
fields: field.fields,
|
|
365
|
+
forceLocalized,
|
|
366
|
+
indexes,
|
|
367
|
+
locales,
|
|
368
|
+
localesColumns,
|
|
369
|
+
localesIndexes,
|
|
370
|
+
newTableName,
|
|
371
|
+
parentTableName,
|
|
372
|
+
relationships,
|
|
373
|
+
relationsToBuild,
|
|
374
|
+
rootRelationsToBuild,
|
|
375
|
+
rootTableIDColType,
|
|
376
|
+
rootTableName,
|
|
377
|
+
uniqueRelationships,
|
|
378
|
+
versions,
|
|
379
|
+
withinLocalizedArrayOrBlock
|
|
380
|
+
});
|
|
381
|
+
if (rowHasLocalizedField) {
|
|
382
|
+
hasLocalizedField = true;
|
|
383
|
+
}
|
|
384
|
+
if (rowHasLocalizedRelationshipField) {
|
|
385
|
+
hasLocalizedRelationshipField = true;
|
|
386
|
+
}
|
|
387
|
+
if (rowHasManyTextField) {
|
|
388
|
+
hasManyTextField = true;
|
|
389
|
+
}
|
|
390
|
+
if (rowHasLocalizedManyTextField) {
|
|
391
|
+
hasLocalizedManyTextField = true;
|
|
392
|
+
}
|
|
393
|
+
if (rowHasManyNumberField) {
|
|
394
|
+
hasManyNumberField = true;
|
|
395
|
+
}
|
|
396
|
+
if (rowHasLocalizedManyNumberField) {
|
|
397
|
+
hasLocalizedManyNumberField = true;
|
|
398
|
+
}
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
case 'date':
|
|
402
|
+
{
|
|
403
|
+
targetTable[fieldName] = withDefault(text(columnName), field);
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
498
406
|
case 'group':
|
|
407
|
+
case 'tab':
|
|
499
408
|
{
|
|
500
409
|
if (!('name' in field)) {
|
|
501
410
|
const { hasLocalizedField: groupHasLocalizedField, hasLocalizedManyNumberField: groupHasLocalizedManyNumberField, hasLocalizedManyTextField: groupHasLocalizedManyTextField, hasLocalizedRelationshipField: groupHasLocalizedRelationshipField, hasManyNumberField: groupHasManyNumberField, hasManyTextField: groupHasManyTextField } = traverseFields({
|
|
@@ -508,7 +417,6 @@ export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull,
|
|
|
508
417
|
fields: field.fields,
|
|
509
418
|
forceLocalized,
|
|
510
419
|
indexes,
|
|
511
|
-
joins,
|
|
512
420
|
locales,
|
|
513
421
|
localesColumns,
|
|
514
422
|
localesIndexes,
|
|
@@ -554,7 +462,6 @@ export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull,
|
|
|
554
462
|
fields: field.fields,
|
|
555
463
|
forceLocalized: field.localized,
|
|
556
464
|
indexes,
|
|
557
|
-
joins,
|
|
558
465
|
locales,
|
|
559
466
|
localesColumns,
|
|
560
467
|
localesIndexes,
|
|
@@ -589,103 +496,122 @@ export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull,
|
|
|
589
496
|
}
|
|
590
497
|
break;
|
|
591
498
|
}
|
|
592
|
-
case '
|
|
499
|
+
case 'json':
|
|
500
|
+
case 'richText':
|
|
593
501
|
{
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
rootRelationsToBuild,
|
|
617
|
-
rootTableIDColType,
|
|
618
|
-
rootTableName,
|
|
619
|
-
uniqueRelationships,
|
|
620
|
-
versions,
|
|
621
|
-
withinLocalizedArrayOrBlock
|
|
622
|
-
});
|
|
623
|
-
if (tabHasLocalizedField) {
|
|
624
|
-
hasLocalizedField = true;
|
|
625
|
-
}
|
|
626
|
-
if (tabHasLocalizedRelationshipField) {
|
|
627
|
-
hasLocalizedRelationshipField = true;
|
|
628
|
-
}
|
|
629
|
-
if (tabHasManyTextField) {
|
|
630
|
-
hasManyTextField = true;
|
|
631
|
-
}
|
|
632
|
-
if (tabHasLocalizedManyTextField) {
|
|
633
|
-
hasLocalizedManyTextField = true;
|
|
634
|
-
}
|
|
635
|
-
if (tabHasManyNumberField) {
|
|
636
|
-
hasManyNumberField = true;
|
|
637
|
-
}
|
|
638
|
-
if (tabHasLocalizedManyNumberField) {
|
|
639
|
-
hasLocalizedManyNumberField = true;
|
|
502
|
+
targetTable[fieldName] = withDefault(text(columnName, {
|
|
503
|
+
mode: 'json'
|
|
504
|
+
}), field);
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
507
|
+
case 'number':
|
|
508
|
+
{
|
|
509
|
+
if (field.hasMany) {
|
|
510
|
+
const isLocalized = Boolean(field.localized && adapter.payload.config.localization) || withinLocalizedArrayOrBlock || forceLocalized;
|
|
511
|
+
if (isLocalized) {
|
|
512
|
+
hasLocalizedManyNumberField = true;
|
|
513
|
+
}
|
|
514
|
+
if (field.index) {
|
|
515
|
+
hasManyNumberField = 'index';
|
|
516
|
+
} else if (!hasManyNumberField) {
|
|
517
|
+
hasManyNumberField = true;
|
|
518
|
+
}
|
|
519
|
+
if (field.unique) {
|
|
520
|
+
throw new InvalidConfiguration('Unique is not supported in Postgres for hasMany number fields.');
|
|
521
|
+
}
|
|
522
|
+
} else {
|
|
523
|
+
targetTable[fieldName] = withDefault(numeric(columnName), field);
|
|
640
524
|
}
|
|
641
525
|
break;
|
|
642
526
|
}
|
|
643
|
-
case '
|
|
644
|
-
case 'collapsible':
|
|
527
|
+
case 'point':
|
|
645
528
|
{
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
indexes,
|
|
657
|
-
joins,
|
|
658
|
-
locales,
|
|
659
|
-
localesColumns,
|
|
660
|
-
localesIndexes,
|
|
661
|
-
newTableName,
|
|
662
|
-
parentTableName,
|
|
663
|
-
relationships,
|
|
664
|
-
relationsToBuild,
|
|
665
|
-
rootRelationsToBuild,
|
|
666
|
-
rootTableIDColType,
|
|
667
|
-
rootTableName,
|
|
668
|
-
uniqueRelationships,
|
|
669
|
-
versions,
|
|
670
|
-
withinLocalizedArrayOrBlock
|
|
529
|
+
break;
|
|
530
|
+
}
|
|
531
|
+
case 'radio':
|
|
532
|
+
case 'select':
|
|
533
|
+
{
|
|
534
|
+
const options = field.options.map((option)=>{
|
|
535
|
+
if (optionIsObject(option)) {
|
|
536
|
+
return option.value;
|
|
537
|
+
}
|
|
538
|
+
return option;
|
|
671
539
|
});
|
|
672
|
-
if (
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
540
|
+
if (field.type === 'select' && field.hasMany) {
|
|
541
|
+
const selectTableName = createTableName({
|
|
542
|
+
adapter,
|
|
543
|
+
config: field,
|
|
544
|
+
parentTableName: newTableName,
|
|
545
|
+
prefix: `${newTableName}_`,
|
|
546
|
+
versionsCustomName: versions
|
|
547
|
+
});
|
|
548
|
+
const baseColumns = {
|
|
549
|
+
order: integer('order').notNull(),
|
|
550
|
+
parent: getIDColumn({
|
|
551
|
+
name: 'parent_id',
|
|
552
|
+
type: parentIDColType,
|
|
553
|
+
notNull: true,
|
|
554
|
+
primaryKey: false
|
|
555
|
+
}),
|
|
556
|
+
value: text('value', {
|
|
557
|
+
enum: options
|
|
558
|
+
})
|
|
559
|
+
};
|
|
560
|
+
const baseExtraConfig = {
|
|
561
|
+
orderIdx: (cols)=>index(`${selectTableName}_order_idx`).on(cols.order),
|
|
562
|
+
parentFk: (cols)=>foreignKey({
|
|
563
|
+
name: `${selectTableName}_parent_fk`,
|
|
564
|
+
columns: [
|
|
565
|
+
cols.parent
|
|
566
|
+
],
|
|
567
|
+
foreignColumns: [
|
|
568
|
+
adapter.tables[parentTableName].id
|
|
569
|
+
]
|
|
570
|
+
}).onDelete('cascade'),
|
|
571
|
+
parentIdx: (cols)=>index(`${selectTableName}_parent_idx`).on(cols.parent)
|
|
572
|
+
};
|
|
573
|
+
const isLocalized = Boolean(field.localized && adapter.payload.config.localization) || withinLocalizedArrayOrBlock || forceLocalized;
|
|
574
|
+
if (isLocalized) {
|
|
575
|
+
baseColumns.locale = text('locale', {
|
|
576
|
+
enum: locales
|
|
577
|
+
}).notNull();
|
|
578
|
+
baseExtraConfig.localeIdx = (cols)=>index(`${selectTableName}_locale_idx`).on(cols.locale);
|
|
579
|
+
}
|
|
580
|
+
if (field.index) {
|
|
581
|
+
baseExtraConfig.value = (cols)=>index(`${selectTableName}_value_idx`).on(cols.value);
|
|
582
|
+
}
|
|
583
|
+
buildTable({
|
|
584
|
+
adapter,
|
|
585
|
+
baseColumns,
|
|
586
|
+
baseExtraConfig,
|
|
587
|
+
disableNotNull,
|
|
588
|
+
disableUnique,
|
|
589
|
+
fields: [],
|
|
590
|
+
rootTableName,
|
|
591
|
+
tableName: selectTableName,
|
|
592
|
+
versions
|
|
593
|
+
});
|
|
594
|
+
relationsToBuild.set(fieldName, {
|
|
595
|
+
type: 'many',
|
|
596
|
+
// selects have their own localized table, independent of the base table.
|
|
597
|
+
localized: false,
|
|
598
|
+
target: selectTableName
|
|
599
|
+
});
|
|
600
|
+
adapter.relations[`relations_${selectTableName}`] = relations(adapter.tables[selectTableName], ({ one })=>({
|
|
601
|
+
parent: one(adapter.tables[parentTableName], {
|
|
602
|
+
fields: [
|
|
603
|
+
adapter.tables[selectTableName].parent
|
|
604
|
+
],
|
|
605
|
+
references: [
|
|
606
|
+
adapter.tables[parentTableName].id
|
|
607
|
+
],
|
|
608
|
+
relationName: fieldName
|
|
609
|
+
})
|
|
610
|
+
}));
|
|
611
|
+
} else {
|
|
612
|
+
targetTable[fieldName] = withDefault(text(columnName, {
|
|
613
|
+
enum: options
|
|
614
|
+
}), field);
|
|
689
615
|
}
|
|
690
616
|
break;
|
|
691
617
|
}
|
|
@@ -740,26 +666,74 @@ export const traverseFields = ({ adapter, columnPrefix, columns, disableNotNull,
|
|
|
740
666
|
hasLocalizedRelationshipField = true;
|
|
741
667
|
}
|
|
742
668
|
break;
|
|
743
|
-
case '
|
|
669
|
+
case 'tabs':
|
|
744
670
|
{
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
671
|
+
const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull;
|
|
672
|
+
const { hasLocalizedField: tabHasLocalizedField, hasLocalizedManyNumberField: tabHasLocalizedManyNumberField, hasLocalizedManyTextField: tabHasLocalizedManyTextField, hasLocalizedRelationshipField: tabHasLocalizedRelationshipField, hasManyNumberField: tabHasManyNumberField, hasManyTextField: tabHasManyTextField } = traverseFields({
|
|
673
|
+
adapter,
|
|
674
|
+
columnPrefix,
|
|
675
|
+
columns,
|
|
676
|
+
disableNotNull: disableNotNullFromHere,
|
|
677
|
+
disableUnique,
|
|
678
|
+
fieldPrefix,
|
|
679
|
+
fields: field.tabs.map((tab)=>({
|
|
680
|
+
...tab,
|
|
681
|
+
type: 'tab'
|
|
682
|
+
})),
|
|
683
|
+
forceLocalized,
|
|
684
|
+
indexes,
|
|
685
|
+
locales,
|
|
686
|
+
localesColumns,
|
|
687
|
+
localesIndexes,
|
|
688
|
+
newTableName,
|
|
689
|
+
parentTableName,
|
|
690
|
+
relationships,
|
|
691
|
+
relationsToBuild,
|
|
692
|
+
rootRelationsToBuild,
|
|
693
|
+
rootTableIDColType,
|
|
694
|
+
rootTableName,
|
|
695
|
+
uniqueRelationships,
|
|
696
|
+
versions,
|
|
697
|
+
withinLocalizedArrayOrBlock
|
|
698
|
+
});
|
|
699
|
+
if (tabHasLocalizedField) {
|
|
700
|
+
hasLocalizedField = true;
|
|
701
|
+
}
|
|
702
|
+
if (tabHasLocalizedRelationshipField) {
|
|
703
|
+
hasLocalizedRelationshipField = true;
|
|
704
|
+
}
|
|
705
|
+
if (tabHasManyTextField) {
|
|
706
|
+
hasManyTextField = true;
|
|
707
|
+
}
|
|
708
|
+
if (tabHasLocalizedManyTextField) {
|
|
709
|
+
hasLocalizedManyTextField = true;
|
|
710
|
+
}
|
|
711
|
+
if (tabHasManyNumberField) {
|
|
712
|
+
hasManyNumberField = true;
|
|
713
|
+
}
|
|
714
|
+
if (tabHasLocalizedManyNumberField) {
|
|
715
|
+
hasLocalizedManyNumberField = true;
|
|
716
|
+
}
|
|
717
|
+
break;
|
|
718
|
+
}
|
|
719
|
+
case 'text':
|
|
720
|
+
{
|
|
721
|
+
if (field.hasMany) {
|
|
722
|
+
const isLocalized = Boolean(field.localized && adapter.payload.config.localization) || withinLocalizedArrayOrBlock || forceLocalized;
|
|
723
|
+
if (isLocalized) {
|
|
724
|
+
hasLocalizedManyTextField = true;
|
|
725
|
+
}
|
|
726
|
+
if (field.index) {
|
|
727
|
+
hasManyTextField = 'index';
|
|
728
|
+
} else if (!hasManyTextField) {
|
|
729
|
+
hasManyTextField = true;
|
|
730
|
+
}
|
|
731
|
+
if (field.unique) {
|
|
732
|
+
throw new InvalidConfiguration('Unique is not supported in SQLite for hasMany text fields.');
|
|
733
|
+
}
|
|
753
734
|
} else {
|
|
754
|
-
|
|
735
|
+
targetTable[fieldName] = withDefault(text(columnName), field);
|
|
755
736
|
}
|
|
756
|
-
relationsToBuild.set(fieldName, {
|
|
757
|
-
type: 'many',
|
|
758
|
-
// joins are not localized on the parent table
|
|
759
|
-
localized: false,
|
|
760
|
-
relationName: field.on.replaceAll('.', '_'),
|
|
761
|
-
target
|
|
762
|
-
});
|
|
763
737
|
break;
|
|
764
738
|
}
|
|
765
739
|
default:
|