@payloadcms/drizzle 4.0.0-internal.af6aad0 → 4.0.0-internal.b8a92d2

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.
Files changed (97) hide show
  1. package/dist/find/buildPolymorphicJoinQuery.d.ts +38 -0
  2. package/dist/find/buildPolymorphicJoinQuery.d.ts.map +1 -0
  3. package/dist/find/buildPolymorphicJoinQuery.js +135 -0
  4. package/dist/find/buildPolymorphicJoinQuery.js.map +1 -0
  5. package/dist/find/buildPolymorphicJoinWhere.d.ts +20 -0
  6. package/dist/find/buildPolymorphicJoinWhere.d.ts.map +1 -0
  7. package/dist/find/buildPolymorphicJoinWhere.js +301 -0
  8. package/dist/find/buildPolymorphicJoinWhere.js.map +1 -0
  9. package/dist/find/createPolymorphicJoinWherePlan.d.ts +37 -0
  10. package/dist/find/createPolymorphicJoinWherePlan.d.ts.map +1 -0
  11. package/dist/find/createPolymorphicJoinWherePlan.js +191 -0
  12. package/dist/find/createPolymorphicJoinWherePlan.js.map +1 -0
  13. package/dist/find/traverseFields.d.ts.map +1 -1
  14. package/dist/find/traverseFields.js +19 -191
  15. package/dist/find/traverseFields.js.map +1 -1
  16. package/dist/migrate.d.ts.map +1 -1
  17. package/dist/migrate.js +35 -13
  18. package/dist/migrate.js.map +1 -1
  19. package/dist/migrateDown.d.ts +2 -1
  20. package/dist/migrateDown.d.ts.map +1 -1
  21. package/dist/migrateDown.js +12 -2
  22. package/dist/migrateDown.js.map +1 -1
  23. package/dist/migrateFresh.d.ts +4 -2
  24. package/dist/migrateFresh.d.ts.map +1 -1
  25. package/dist/migrateFresh.js +21 -7
  26. package/dist/migrateFresh.js.map +1 -1
  27. package/dist/migrateRefresh.d.ts +2 -1
  28. package/dist/migrateRefresh.d.ts.map +1 -1
  29. package/dist/migrateRefresh.js +14 -3
  30. package/dist/migrateRefresh.js.map +1 -1
  31. package/dist/migrateReset.d.ts +2 -1
  32. package/dist/migrateReset.d.ts.map +1 -1
  33. package/dist/migrateReset.js +12 -2
  34. package/dist/migrateReset.js.map +1 -1
  35. package/dist/migrateStatus.d.ts +2 -1
  36. package/dist/migrateStatus.d.ts.map +1 -1
  37. package/dist/migrateStatus.js +11 -6
  38. package/dist/migrateStatus.js.map +1 -1
  39. package/dist/postgres/createJSONQuery/index.js +3 -3
  40. package/dist/postgres/createJSONQuery/index.js.map +1 -1
  41. package/dist/postgres/predefinedMigrations/v2-v3/index.js +1 -1
  42. package/dist/postgres/predefinedMigrations/v2-v3/index.js.map +1 -1
  43. package/dist/queries/getTableColumnFromPath.d.ts +12 -3
  44. package/dist/queries/getTableColumnFromPath.d.ts.map +1 -1
  45. package/dist/queries/getTableColumnFromPath.js +59 -27
  46. package/dist/queries/getTableColumnFromPath.js.map +1 -1
  47. package/dist/queries/parseParams.d.ts.map +1 -1
  48. package/dist/queries/parseParams.js +210 -5
  49. package/dist/queries/parseParams.js.map +1 -1
  50. package/dist/queries/resolveRelationshipPath.d.ts +36 -0
  51. package/dist/queries/resolveRelationshipPath.d.ts.map +1 -0
  52. package/dist/queries/resolveRelationshipPath.js +66 -0
  53. package/dist/queries/resolveRelationshipPath.js.map +1 -0
  54. package/dist/sqlite/createJSONQuery/convertPathToJSONTraversal.js +3 -2
  55. package/dist/sqlite/createJSONQuery/convertPathToJSONTraversal.js.map +1 -1
  56. package/dist/sqlite/createJSONQuery/index.d.ts.map +1 -1
  57. package/dist/sqlite/createJSONQuery/index.js +6 -5
  58. package/dist/sqlite/createJSONQuery/index.js.map +1 -1
  59. package/dist/transform/write/traverseFields.d.ts.map +1 -1
  60. package/dist/transform/write/traverseFields.js +8 -14
  61. package/dist/transform/write/traverseFields.js.map +1 -1
  62. package/dist/updateOne.d.ts.map +1 -1
  63. package/dist/updateOne.js +41 -1
  64. package/dist/updateOne.js.map +1 -1
  65. package/dist/upsertRow/index.d.ts +1 -1
  66. package/dist/upsertRow/index.d.ts.map +1 -1
  67. package/dist/upsertRow/index.js +25 -5
  68. package/dist/upsertRow/index.js.map +1 -1
  69. package/dist/utilities/buildCreateMigration.d.ts.map +1 -1
  70. package/dist/utilities/buildCreateMigration.js +12 -8
  71. package/dist/utilities/buildCreateMigration.js.map +1 -1
  72. package/dist/utilities/createSchemaGenerator.d.ts.map +1 -1
  73. package/dist/utilities/createSchemaGenerator.js +3 -0
  74. package/dist/utilities/createSchemaGenerator.js.map +1 -1
  75. package/dist/utilities/parseJSONPathSegment.d.ts +9 -0
  76. package/dist/utilities/parseJSONPathSegment.d.ts.map +1 -0
  77. package/dist/utilities/parseJSONPathSegment.js +17 -0
  78. package/dist/utilities/parseJSONPathSegment.js.map +1 -0
  79. package/package.json +3 -3
  80. package/dist/postgres/query/assertOperatorHandlerExtensionsInstalled.spec.js +0 -91
  81. package/dist/postgres/query/assertOperatorHandlerExtensionsInstalled.spec.js.map +0 -1
  82. package/dist/postgres/query/postgresUnaccent.spec.js +0 -71
  83. package/dist/postgres/query/postgresUnaccent.spec.js.map +0 -1
  84. package/dist/queries/buildOperatorConstraint.spec.js +0 -348
  85. package/dist/queries/buildOperatorConstraint.spec.js.map +0 -1
  86. package/dist/queries/validateOperatorHandlers.spec.js +0 -142
  87. package/dist/queries/validateOperatorHandlers.spec.js.map +0 -1
  88. package/dist/schema/buildRawSchema.spec.js +0 -290
  89. package/dist/schema/buildRawSchema.spec.js.map +0 -1
  90. package/dist/upsertRow/handleUpsertError.spec.js +0 -42
  91. package/dist/upsertRow/handleUpsertError.spec.js.map +0 -1
  92. package/dist/utilities/checkTruncatedIdentifiers.spec.js +0 -301
  93. package/dist/utilities/checkTruncatedIdentifiers.spec.js.map +0 -1
  94. package/dist/utilities/isValidStringID.spec.js +0 -15
  95. package/dist/utilities/isValidStringID.spec.js.map +0 -1
  96. package/dist/utilities/validateIdentifierLength.spec.js +0 -19
  97. package/dist/utilities/validateIdentifierLength.spec.js.map +0 -1
@@ -1,142 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { validateOperatorHandlers } from './validateOperatorHandlers.js';
3
- const transformHandler = (overrides = {})=>({
4
- name: 'transform',
5
- operators: [
6
- 'contains'
7
- ],
8
- transformOperands: ({ column, value })=>({
9
- column,
10
- value
11
- }),
12
- ...overrides
13
- });
14
- const replacementHandler = (overrides = {})=>({
15
- name: 'replace',
16
- operators: [
17
- 'contains'
18
- ],
19
- build: ()=>null,
20
- ...overrides
21
- });
22
- describe('validateOperatorHandlers', ()=>{
23
- it('does not throw when zero handlers are configured', ()=>{
24
- expect(()=>validateOperatorHandlers([])).not.toThrow();
25
- });
26
- it('does not throw for any number of non-conflicting operand-transform handlers', ()=>{
27
- expect(()=>validateOperatorHandlers([
28
- transformHandler({
29
- name: 'a'
30
- }),
31
- transformHandler({
32
- name: 'b'
33
- }),
34
- transformHandler({
35
- name: 'c'
36
- })
37
- ])).not.toThrow();
38
- });
39
- it('throws when two build handlers list the same resolved operator, naming both handlers and the operator', ()=>{
40
- expect(()=>validateOperatorHandlers([
41
- replacementHandler({
42
- name: 'handler-a',
43
- operators: [
44
- 'contains'
45
- ]
46
- }),
47
- replacementHandler({
48
- name: 'handler-b',
49
- operators: [
50
- 'contains'
51
- ]
52
- })
53
- ])).toThrow(/handler-a/);
54
- expect(()=>validateOperatorHandlers([
55
- replacementHandler({
56
- name: 'handler-a',
57
- operators: [
58
- 'contains'
59
- ]
60
- }),
61
- replacementHandler({
62
- name: 'handler-b',
63
- operators: [
64
- 'contains'
65
- ]
66
- })
67
- ])).toThrow(/handler-b/);
68
- expect(()=>validateOperatorHandlers([
69
- replacementHandler({
70
- name: 'handler-a',
71
- operators: [
72
- 'contains'
73
- ]
74
- }),
75
- replacementHandler({
76
- name: 'handler-b',
77
- operators: [
78
- 'contains'
79
- ]
80
- })
81
- ])).toThrow(/contains/);
82
- });
83
- it('does not throw when two build handlers target the same operator but declare disjoint fieldTypes', ()=>{
84
- expect(()=>validateOperatorHandlers([
85
- replacementHandler({
86
- name: 'text',
87
- operators: [
88
- 'contains'
89
- ],
90
- fieldTypes: [
91
- 'text'
92
- ]
93
- }),
94
- replacementHandler({
95
- name: 'number',
96
- operators: [
97
- 'contains'
98
- ],
99
- fieldTypes: [
100
- 'number'
101
- ]
102
- })
103
- ])).not.toThrow();
104
- });
105
- it('throws when two build handlers target the same operator and at least one declares no fieldTypes', ()=>{
106
- expect(()=>validateOperatorHandlers([
107
- replacementHandler({
108
- name: 'unrestricted',
109
- operators: [
110
- 'contains'
111
- ]
112
- }),
113
- replacementHandler({
114
- name: 'text',
115
- operators: [
116
- 'contains'
117
- ],
118
- fieldTypes: [
119
- 'text'
120
- ]
121
- })
122
- ])).toThrow();
123
- });
124
- it('throws when a handler object defines both build and transformOperands', ()=>{
125
- const malformed = {
126
- name: 'malformed',
127
- operators: [
128
- 'contains'
129
- ],
130
- build: ()=>null,
131
- transformOperands: ({ column, value })=>({
132
- column,
133
- value
134
- })
135
- };
136
- expect(()=>validateOperatorHandlers([
137
- malformed
138
- ])).toThrow(/malformed/);
139
- });
140
- });
141
-
142
- //# sourceMappingURL=validateOperatorHandlers.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/queries/validateOperatorHandlers.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport type { DrizzleOperatorHandler } from '../types.js'\n\nimport { validateOperatorHandlers } from './validateOperatorHandlers.js'\n\nconst transformHandler = (\n overrides: Partial<DrizzleOperatorHandler> = {},\n): DrizzleOperatorHandler =>\n ({\n name: 'transform',\n operators: ['contains'],\n transformOperands: ({ column, value }) => ({ column, value }),\n ...overrides,\n }) as DrizzleOperatorHandler\n\nconst replacementHandler = (\n overrides: Partial<DrizzleOperatorHandler> = {},\n): DrizzleOperatorHandler =>\n ({\n name: 'replace',\n operators: ['contains'],\n build: () => null as any,\n ...overrides,\n }) as DrizzleOperatorHandler\n\ndescribe('validateOperatorHandlers', () => {\n it('does not throw when zero handlers are configured', () => {\n expect(() => validateOperatorHandlers([])).not.toThrow()\n })\n\n it('does not throw for any number of non-conflicting operand-transform handlers', () => {\n expect(() =>\n validateOperatorHandlers([\n transformHandler({ name: 'a' }),\n transformHandler({ name: 'b' }),\n transformHandler({ name: 'c' }),\n ]),\n ).not.toThrow()\n })\n\n it('throws when two build handlers list the same resolved operator, naming both handlers and the operator', () => {\n expect(() =>\n validateOperatorHandlers([\n replacementHandler({ name: 'handler-a', operators: ['contains'] }),\n replacementHandler({ name: 'handler-b', operators: ['contains'] }),\n ]),\n ).toThrow(/handler-a/)\n\n expect(() =>\n validateOperatorHandlers([\n replacementHandler({ name: 'handler-a', operators: ['contains'] }),\n replacementHandler({ name: 'handler-b', operators: ['contains'] }),\n ]),\n ).toThrow(/handler-b/)\n\n expect(() =>\n validateOperatorHandlers([\n replacementHandler({ name: 'handler-a', operators: ['contains'] }),\n replacementHandler({ name: 'handler-b', operators: ['contains'] }),\n ]),\n ).toThrow(/contains/)\n })\n\n it('does not throw when two build handlers target the same operator but declare disjoint fieldTypes', () => {\n expect(() =>\n validateOperatorHandlers([\n replacementHandler({ name: 'text', operators: ['contains'], fieldTypes: ['text'] }),\n replacementHandler({ name: 'number', operators: ['contains'], fieldTypes: ['number'] }),\n ]),\n ).not.toThrow()\n })\n\n it('throws when two build handlers target the same operator and at least one declares no fieldTypes', () => {\n expect(() =>\n validateOperatorHandlers([\n replacementHandler({ name: 'unrestricted', operators: ['contains'] }),\n replacementHandler({ name: 'text', operators: ['contains'], fieldTypes: ['text'] }),\n ]),\n ).toThrow()\n })\n\n it('throws when a handler object defines both build and transformOperands', () => {\n const malformed = {\n name: 'malformed',\n operators: ['contains'],\n build: () => null as any,\n transformOperands: ({ column, value }: any) => ({ column, value }),\n } as unknown as DrizzleOperatorHandler\n\n expect(() => validateOperatorHandlers([malformed])).toThrow(/malformed/)\n })\n})\n"],"names":["describe","expect","it","validateOperatorHandlers","transformHandler","overrides","name","operators","transformOperands","column","value","replacementHandler","build","not","toThrow","fieldTypes","malformed"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,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ChEI,mBAAmB;oBAAEL,MAAM;oBAAaC,WAAW;wBAAC;qBAAW;gBAAC;aACjE,GACDO,OAAO,CAAC;IACZ;IAEAZ,GAAG,mGAAmG;QACpGD,OAAO,IACLE,yBAAyB;gBACvBQ,mBAAmB;oBAAEL,MAAM;oBAAQC,WAAW;wBAAC;qBAAW;oBAAEQ,YAAY;wBAAC;qBAAO;gBAAC;gBACjFJ,mBAAmB;oBAAEL,MAAM;oBAAUC,WAAW;wBAAC;qBAAW;oBAAEQ,YAAY;wBAAC;qBAAS;gBAAC;aACtF,GACDF,GAAG,CAACC,OAAO;IACf;IAEAZ,GAAG,mGAAmG;QACpGD,OAAO,IACLE,yBAAyB;gBACvBQ,mBAAmB;oBAAEL,MAAM;oBAAgBC,WAAW;wBAAC;qBAAW;gBAAC;gBACnEI,mBAAmB;oBAAEL,MAAM;oBAAQC,WAAW;wBAAC;qBAAW;oBAAEQ,YAAY;wBAAC;qBAAO;gBAAC;aAClF,GACDD,OAAO;IACX;IAEAZ,GAAG,yEAAyE;QAC1E,MAAMc,YAAY;YAChBV,MAAM;YACNC,WAAW;gBAAC;aAAW;YACvBK,OAAO,IAAM;YACbJ,mBAAmB,CAAC,EAAEC,MAAM,EAAEC,KAAK,EAAO,GAAM,CAAA;oBAAED;oBAAQC;gBAAM,CAAA;QAClE;QAEAT,OAAO,IAAME,yBAAyB;gBAACa;aAAU,GAAGF,OAAO,CAAC;IAC9D;AACF"}
@@ -1,290 +0,0 @@
1
- import { sanitizeConfig } from 'payload';
2
- import { describe, expect, it, vi } from 'vitest';
3
- import { setColumnID } from '../postgres/schema/setColumnID.js';
4
- import { checkTruncatedIdentifiers } from '../utilities/checkTruncatedIdentifiers.js';
5
- import { buildRawSchema } from './buildRawSchema.js';
6
- const headlineBlock = {
7
- slug: 'headline',
8
- fields: [
9
- {
10
- name: 'title',
11
- type: 'text'
12
- }
13
- ]
14
- };
15
- const createContainerBlock = (slug)=>({
16
- slug,
17
- fields: [
18
- {
19
- name: 'content',
20
- type: 'blocks',
21
- blocks: [
22
- 'headline'
23
- ]
24
- }
25
- ]
26
- });
27
- const createAdapter = (config, warn = ()=>{})=>({
28
- blocksAsJSON: false,
29
- fieldConstraints: {},
30
- idType: 'serial',
31
- localesSuffix: '_locales',
32
- payload: {
33
- blocks: Object.fromEntries(config.blocks.map((block)=>[
34
- block.slug,
35
- block
36
- ])),
37
- collections: Object.fromEntries(config.collections.map((collection)=>[
38
- collection.slug,
39
- {
40
- config: collection,
41
- customIDType: undefined
42
- }
43
- ])),
44
- config,
45
- logger: {
46
- warn
47
- }
48
- },
49
- rawRelations: {},
50
- rawTables: {},
51
- tableNameMap: new Map(),
52
- versionsSuffix: '_versions'
53
- });
54
- describe('buildRawSchema', ()=>{
55
- it('should create suffixed block tables for different schemas with the same slug', async ()=>{
56
- const config = sanitizeConfig({
57
- collections: [
58
- {
59
- slug: 'pages',
60
- fields: [
61
- {
62
- name: 'primaryContent',
63
- type: 'blocks',
64
- localized: true,
65
- blocks: [
66
- {
67
- slug: 'content',
68
- fields: [
69
- {
70
- name: 'title',
71
- type: 'text'
72
- }
73
- ]
74
- }
75
- ]
76
- },
77
- {
78
- name: 'secondaryContent',
79
- type: 'blocks',
80
- localized: true,
81
- blocks: [
82
- {
83
- slug: 'content',
84
- fields: [
85
- {
86
- name: 'description',
87
- type: 'textarea'
88
- }
89
- ]
90
- }
91
- ]
92
- }
93
- ]
94
- }
95
- ],
96
- localization: {
97
- defaultLocale: 'en',
98
- locales: [
99
- 'en',
100
- 'de'
101
- ]
102
- }
103
- });
104
- const adapter = createAdapter(config);
105
- buildRawSchema({
106
- adapter,
107
- setColumnID
108
- });
109
- expect(adapter.rawTables.pages_blocks_content.columns.title).toBeDefined();
110
- expect(adapter.rawTables.pages_blocks_content.columns._locale).toBeDefined();
111
- expect(adapter.rawTables.pages_blocks_content_2.columns.description).toBeDefined();
112
- expect(adapter.rawTables.pages_blocks_content_2.columns._locale).toBeDefined();
113
- });
114
- it('should not create duplicate suffixed block tables for identical reused blocks under localized ancestors', async ()=>{
115
- const layoutBlocks = [
116
- createContainerBlock('container'),
117
- createContainerBlock('container50')
118
- ];
119
- const config = sanitizeConfig({
120
- blocks: [
121
- headlineBlock
122
- ],
123
- collections: [
124
- {
125
- slug: 'pages',
126
- fields: [
127
- {
128
- name: 'layout',
129
- type: 'blocks',
130
- localized: true,
131
- blocks: layoutBlocks
132
- }
133
- ]
134
- },
135
- {
136
- slug: 'posts',
137
- fields: [
138
- {
139
- name: 'layout',
140
- type: 'blocks',
141
- localized: true,
142
- blocks: layoutBlocks
143
- }
144
- ]
145
- }
146
- ],
147
- localization: {
148
- defaultLocale: 'en',
149
- locales: [
150
- 'en',
151
- 'de'
152
- ]
153
- }
154
- });
155
- const adapter = createAdapter(config);
156
- buildRawSchema({
157
- adapter,
158
- setColumnID
159
- });
160
- expect(adapter.rawTables.pages_blocks_headline).toBeDefined();
161
- expect(adapter.rawTables.pages_blocks_headline.columns._locale).toBeDefined();
162
- expect(adapter.rawTables.pages_blocks_headline_2).toBeUndefined();
163
- expect(adapter.rawTables.pages_blocks_headline_2_locales).toBeUndefined();
164
- expect(adapter.rawTables.posts_blocks_headline).toBeDefined();
165
- expect(adapter.rawTables.posts_blocks_headline.columns._locale).toBeDefined();
166
- expect(adapter.rawTables.posts_blocks_headline_2).toBeUndefined();
167
- expect(adapter.rawTables.posts_blocks_headline_2_locales).toBeUndefined();
168
- });
169
- it('should warn when a localized field pushes the _locales companion table past 63 chars', async ()=>{
170
- // Base table name (61 chars) is under the limit, but `${base}_locales` (69) overflows it.
171
- const longSlug = `localized_collection_${'x'.repeat(40)}`;
172
- const config = sanitizeConfig({
173
- collections: [
174
- {
175
- slug: longSlug,
176
- fields: [
177
- {
178
- name: 'title',
179
- type: 'text',
180
- localized: true
181
- }
182
- ],
183
- timestamps: false,
184
- versions: false
185
- }
186
- ],
187
- localization: {
188
- defaultLocale: 'en',
189
- locales: [
190
- 'en',
191
- 'de'
192
- ]
193
- }
194
- });
195
- const warn = vi.fn();
196
- const adapter = createAdapter(config, warn);
197
- buildRawSchema({
198
- adapter,
199
- setColumnID
200
- });
201
- expect(adapter.rawTables[`${longSlug}_locales`]).toBeDefined();
202
- expect(()=>checkTruncatedIdentifiers({
203
- adapter,
204
- logWarnings: true
205
- })).not.toThrow();
206
- expect(warn).toHaveBeenCalledTimes(1);
207
- expect(warn.mock.calls[0][0]).toContain(`${longSlug}_locales`);
208
- });
209
- it('should not warn when the _locales companion table fits within 63 chars', async ()=>{
210
- const config = sanitizeConfig({
211
- collections: [
212
- {
213
- slug: 'short_localized',
214
- fields: [
215
- {
216
- name: 'title',
217
- type: 'text',
218
- localized: true
219
- }
220
- ],
221
- timestamps: false,
222
- versions: false
223
- }
224
- ],
225
- localization: {
226
- defaultLocale: 'en',
227
- locales: [
228
- 'en',
229
- 'de'
230
- ]
231
- }
232
- });
233
- const warn = vi.fn();
234
- const adapter = createAdapter(config, warn);
235
- buildRawSchema({
236
- adapter,
237
- setColumnID
238
- });
239
- expect(adapter.rawTables.short_localized_locales).toBeDefined();
240
- checkTruncatedIdentifiers({
241
- adapter,
242
- logWarnings: true
243
- });
244
- expect(warn).not.toHaveBeenCalled();
245
- });
246
- it('should warn about raw inline sub-table index and foreign key names that exceed 63 chars', async ()=>{
247
- // Array sub-tables assign structural index/FK names inline (not via buildIndexName/
248
- // buildForeignKeyName), so a long-but-valid array table name still overflows them.
249
- const arrayFieldName = 'a'.repeat(58);
250
- const config = sanitizeConfig({
251
- collections: [
252
- {
253
- slug: 'p',
254
- fields: [
255
- {
256
- name: arrayFieldName,
257
- type: 'array',
258
- fields: [
259
- {
260
- name: 'title',
261
- type: 'text'
262
- }
263
- ]
264
- }
265
- ],
266
- timestamps: false,
267
- versions: false
268
- }
269
- ]
270
- });
271
- const warn = vi.fn();
272
- const adapter = createAdapter(config, warn);
273
- buildRawSchema({
274
- adapter,
275
- setColumnID
276
- });
277
- const arrayTable = `p_${arrayFieldName}`;
278
- checkTruncatedIdentifiers({
279
- adapter,
280
- logWarnings: true
281
- });
282
- expect(arrayTable.length).toBeLessThanOrEqual(63);
283
- expect(warn).toHaveBeenCalledTimes(1);
284
- const message = warn.mock.calls[0][0];
285
- expect(message).toContain(`${arrayTable}_order_idx`);
286
- expect(message).toContain(`${arrayTable}_parent_id_fk`);
287
- });
288
- });
289
-
290
- //# sourceMappingURL=buildRawSchema.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/schema/buildRawSchema.spec.ts"],"sourcesContent":["import type { Block, Config, SanitizedConfig } from 'payload'\nimport { sanitizeConfig } from 'payload'\nimport { describe, expect, it, vi } from 'vitest'\n\nimport { setColumnID } from '../postgres/schema/setColumnID.js'\nimport type { DrizzleAdapter } from '../types.js'\nimport { checkTruncatedIdentifiers } from '../utilities/checkTruncatedIdentifiers.js'\nimport { buildRawSchema } from './buildRawSchema.js'\n\nconst headlineBlock: Block = {\n slug: 'headline',\n fields: [\n {\n name: 'title',\n type: 'text',\n },\n ],\n}\n\nconst createContainerBlock = (slug: string): Block => ({\n slug,\n fields: [\n {\n name: 'content',\n type: 'blocks',\n blocks: ['headline'],\n },\n ],\n})\n\nconst createAdapter = (\n config: SanitizedConfig,\n warn: (...args: any[]) => void = () => {},\n): DrizzleAdapter =>\n ({\n blocksAsJSON: false,\n fieldConstraints: {},\n idType: 'serial',\n localesSuffix: '_locales',\n payload: {\n blocks: Object.fromEntries(config.blocks.map((block) => [block.slug, block])),\n collections: Object.fromEntries(\n config.collections.map((collection) => [\n collection.slug,\n {\n config: collection,\n customIDType: undefined,\n },\n ]),\n ),\n config,\n logger: { warn },\n },\n rawRelations: {},\n rawTables: {},\n tableNameMap: new Map(),\n versionsSuffix: '_versions',\n }) as unknown as DrizzleAdapter\n\ndescribe('buildRawSchema', () => {\n it('should create suffixed block tables for different schemas with the same slug', async () => {\n const config = sanitizeConfig({\n collections: [\n {\n slug: 'pages',\n fields: [\n {\n name: 'primaryContent',\n type: 'blocks',\n localized: true,\n blocks: [\n {\n slug: 'content',\n fields: [\n {\n name: 'title',\n type: 'text',\n },\n ],\n },\n ],\n },\n {\n name: 'secondaryContent',\n type: 'blocks',\n localized: true,\n blocks: [\n {\n slug: 'content',\n fields: [\n {\n name: 'description',\n type: 'textarea',\n },\n ],\n },\n ],\n },\n ],\n },\n ],\n localization: {\n defaultLocale: 'en',\n locales: ['en', 'de'],\n },\n } as Config)\n\n const adapter = createAdapter(config)\n\n buildRawSchema({\n adapter,\n setColumnID,\n })\n\n expect(adapter.rawTables.pages_blocks_content.columns.title).toBeDefined()\n expect(adapter.rawTables.pages_blocks_content.columns._locale).toBeDefined()\n expect(adapter.rawTables.pages_blocks_content_2.columns.description).toBeDefined()\n expect(adapter.rawTables.pages_blocks_content_2.columns._locale).toBeDefined()\n })\n\n it('should not create duplicate suffixed block tables for identical reused blocks under localized ancestors', async () => {\n const layoutBlocks = [createContainerBlock('container'), createContainerBlock('container50')]\n\n const config = sanitizeConfig({\n blocks: [headlineBlock],\n collections: [\n {\n slug: 'pages',\n fields: [\n {\n name: 'layout',\n type: 'blocks',\n localized: true,\n blocks: layoutBlocks,\n },\n ],\n },\n {\n slug: 'posts',\n fields: [\n {\n name: 'layout',\n type: 'blocks',\n localized: true,\n blocks: layoutBlocks,\n },\n ],\n },\n ],\n localization: {\n defaultLocale: 'en',\n locales: ['en', 'de'],\n },\n } as Config)\n\n const adapter = createAdapter(config)\n\n buildRawSchema({\n adapter,\n setColumnID,\n })\n\n expect(adapter.rawTables.pages_blocks_headline).toBeDefined()\n expect(adapter.rawTables.pages_blocks_headline.columns._locale).toBeDefined()\n expect(adapter.rawTables.pages_blocks_headline_2).toBeUndefined()\n expect(adapter.rawTables.pages_blocks_headline_2_locales).toBeUndefined()\n expect(adapter.rawTables.posts_blocks_headline).toBeDefined()\n expect(adapter.rawTables.posts_blocks_headline.columns._locale).toBeDefined()\n expect(adapter.rawTables.posts_blocks_headline_2).toBeUndefined()\n expect(adapter.rawTables.posts_blocks_headline_2_locales).toBeUndefined()\n })\n\n it('should warn when a localized field pushes the _locales companion table past 63 chars', async () => {\n // Base table name (61 chars) is under the limit, but `${base}_locales` (69) overflows it.\n const longSlug = `localized_collection_${'x'.repeat(40)}`\n\n const config = sanitizeConfig({\n collections: [\n {\n slug: longSlug,\n fields: [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n localization: {\n defaultLocale: 'en',\n locales: ['en', 'de'],\n },\n } as Config)\n\n const warn = vi.fn()\n const adapter = createAdapter(config, warn)\n\n buildRawSchema({ adapter, setColumnID })\n\n expect(adapter.rawTables[`${longSlug}_locales`]).toBeDefined()\n\n expect(() => checkTruncatedIdentifiers({ adapter, logWarnings: true })).not.toThrow()\n expect(warn).toHaveBeenCalledTimes(1)\n expect(warn.mock.calls[0][0]).toContain(`${longSlug}_locales`)\n })\n\n it('should not warn when the _locales companion table fits within 63 chars', async () => {\n const config = sanitizeConfig({\n collections: [\n {\n slug: 'short_localized',\n fields: [\n {\n name: 'title',\n type: 'text',\n localized: true,\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n localization: {\n defaultLocale: 'en',\n locales: ['en', 'de'],\n },\n } as Config)\n\n const warn = vi.fn()\n const adapter = createAdapter(config, warn)\n\n buildRawSchema({ adapter, setColumnID })\n\n expect(adapter.rawTables.short_localized_locales).toBeDefined()\n\n checkTruncatedIdentifiers({ adapter, logWarnings: true })\n\n expect(warn).not.toHaveBeenCalled()\n })\n\n it('should warn about raw inline sub-table index and foreign key names that exceed 63 chars', async () => {\n // Array sub-tables assign structural index/FK names inline (not via buildIndexName/\n // buildForeignKeyName), so a long-but-valid array table name still overflows them.\n const arrayFieldName = 'a'.repeat(58)\n\n const config = sanitizeConfig({\n collections: [\n {\n slug: 'p',\n fields: [\n {\n name: arrayFieldName,\n type: 'array',\n fields: [{ name: 'title', type: 'text' }],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n } as Config)\n\n const warn = vi.fn()\n const adapter = createAdapter(config, warn)\n\n buildRawSchema({ adapter, setColumnID })\n\n const arrayTable = `p_${arrayFieldName}`\n\n checkTruncatedIdentifiers({ adapter, logWarnings: true })\n\n expect(arrayTable.length).toBeLessThanOrEqual(63)\n expect(warn).toHaveBeenCalledTimes(1)\n\n const message: string = warn.mock.calls[0][0]\n\n expect(message).toContain(`${arrayTable}_order_idx`)\n expect(message).toContain(`${arrayTable}_parent_id_fk`)\n })\n})\n"],"names":["sanitizeConfig","describe","expect","it","vi","setColumnID","checkTruncatedIdentifiers","buildRawSchema","headlineBlock","slug","fields","name","type","createContainerBlock","blocks","createAdapter","config","warn","blocksAsJSON","fieldConstraints","idType","localesSuffix","payload","Object","fromEntries","map","block","collections","collection","customIDType","undefined","logger","rawRelations","rawTables","tableNameMap","Map","versionsSuffix","localized","localization","defaultLocale","locales","adapter","pages_blocks_content","columns","title","toBeDefined","_locale","pages_blocks_content_2","description","layoutBlocks","pages_blocks_headline","pages_blocks_headline_2","toBeUndefined","pages_blocks_headline_2_locales","posts_blocks_headline","posts_blocks_headline_2","posts_blocks_headline_2_locales","longSlug","repeat","timestamps","versions","fn","logWarnings","not","toThrow","toHaveBeenCalledTimes","mock","calls","toContain","short_localized_locales","toHaveBeenCalled","arrayFieldName","arrayTable","length","toBeLessThanOrEqual","message"],"mappings":"AACA,SAASA,cAAc,QAAQ,UAAS;AACxC,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,SAAQ;AAEjD,SAASC,WAAW,QAAQ,oCAAmC;AAE/D,SAASC,yBAAyB,QAAQ,4CAA2C;AACrF,SAASC,cAAc,QAAQ,sBAAqB;AAEpD,MAAMC,gBAAuB;IAC3BC,MAAM;IACNC,QAAQ;QACN;YACEC,MAAM;YACNC,MAAM;QACR;KACD;AACH;AAEA,MAAMC,uBAAuB,CAACJ,OAAyB,CAAA;QACrDA;QACAC,QAAQ;YACN;gBACEC,MAAM;gBACNC,MAAM;gBACNE,QAAQ;oBAAC;iBA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AY;QAEtCH,OAAOuC,QAAQR,SAAS,CAACoC,uBAAuB,EAAExB,WAAW;QAE7DvC,0BAA0B;YAAEmC;YAASqB,aAAa;QAAK;QAEvD5D,OAAOe,MAAM8C,GAAG,CAACO,gBAAgB;IACnC;IAEAnE,GAAG,2FAA2F;QAC5F,oFAAoF;QACpF,mFAAmF;QACnF,MAAMoE,iBAAiB,IAAIb,MAAM,CAAC;QAElC,MAAM1C,SAAShB,eAAe;YAC5B2B,aAAa;gBACX;oBACElB,MAAM;oBACNC,QAAQ;wBACN;4BACEC,MAAM4D;4BACN3D,MAAM;4BACNF,QAAQ;gCAAC;oCAAEC,MAAM;oCAASC,MAAM;gCAAO;6BAAE;wBAC3C;qBACD;oBACD+C,YAAY;oBACZC,UAAU;gBACZ;aACD;QACH;QAEA,MAAM3C,OAAOb,GAAGyD,EAAE;QAClB,MAAMpB,UAAU1B,cAAcC,QAAQC;QAEtCV,eAAe;YAAEkC;YAASpC;QAAY;QAEtC,MAAMmE,aAAa,CAAC,EAAE,EAAED,gBAAgB;QAExCjE,0BAA0B;YAAEmC;YAASqB,aAAa;QAAK;QAEvD5D,OAAOsE,WAAWC,MAAM,EAAEC,mBAAmB,CAAC;QAC9CxE,OAAOe,MAAMgD,qBAAqB,CAAC;QAEnC,MAAMU,UAAkB1D,KAAKiD,IAAI,CAACC,KAAK,CAAC,EAAE,CAAC,EAAE;QAE7CjE,OAAOyE,SAASP,SAAS,CAAC,GAAGI,WAAW,UAAU,CAAC;QACnDtE,OAAOyE,SAASP,SAAS,CAAC,GAAGI,WAAW,aAAa,CAAC;IACxD;AACF"}
@@ -1,42 +0,0 @@
1
- import { ValidationError } from 'payload';
2
- import { describe, expect, it } from 'vitest';
3
- import { handleUpsertError } from './handleUpsertError.js';
4
- const adapter = {
5
- fieldConstraints: {}
6
- };
7
- describe('handleUpsertError', ()=>{
8
- it('preserves the failing sub-table name on the ValidationError', ()=>{
9
- const pgError = {
10
- code: '23505',
11
- constraint: 'ultrasonic_avail_country_pkey',
12
- detail: 'Key (id)=(6a27e2a63f4b64567370f595) already exists.'
13
- };
14
- let thrown;
15
- try {
16
- handleUpsertError({
17
- adapter,
18
- collectionSlug: 'ultrasonic',
19
- error: pgError,
20
- tableName: 'ultrasonic_avail_country'
21
- });
22
- } catch (error) {
23
- thrown = error;
24
- }
25
- expect(thrown).toBeInstanceOf(ValidationError);
26
- const validationError = thrown;
27
- const fieldError = validationError.data.errors[0];
28
- expect(fieldError.path).toBe('id');
29
- expect(fieldError.tableName).toBe('ultrasonic_avail_country');
30
- });
31
- it('re-throws non unique-constraint errors unchanged', ()=>{
32
- const otherError = new Error('some other db error');
33
- expect(()=>handleUpsertError({
34
- adapter,
35
- collectionSlug: 'ultrasonic',
36
- error: otherError,
37
- tableName: 'ultrasonic_avail_country'
38
- })).toThrow(otherError);
39
- });
40
- });
41
-
42
- //# sourceMappingURL=handleUpsertError.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/upsertRow/handleUpsertError.spec.ts"],"sourcesContent":["import { ValidationError } from 'payload'\nimport { describe, expect, it } from 'vitest'\n\nimport type { DrizzleAdapter } from '../types.js'\n\nimport { handleUpsertError } from './handleUpsertError.js'\n\nconst adapter = { fieldConstraints: {} } as unknown as DrizzleAdapter\n\ndescribe('handleUpsertError', () => {\n it('preserves the failing sub-table name on the ValidationError', () => {\n const pgError = {\n code: '23505',\n constraint: 'ultrasonic_avail_country_pkey',\n detail: 'Key (id)=(6a27e2a63f4b64567370f595) already exists.',\n }\n\n let thrown: unknown\n try {\n handleUpsertError({\n adapter,\n collectionSlug: 'ultrasonic',\n error: pgError,\n tableName: 'ultrasonic_avail_country',\n })\n } catch (error) {\n thrown = error\n }\n\n expect(thrown).toBeInstanceOf(ValidationError)\n const validationError = thrown as ValidationError\n const fieldError = validationError.data.errors[0]!\n expect(fieldError.path).toBe('id')\n expect(fieldError.tableName).toBe('ultrasonic_avail_country')\n })\n\n it('re-throws non unique-constraint errors unchanged', () => {\n const otherError = new Error('some other db error')\n\n expect(() =>\n handleUpsertError({\n adapter,\n collectionSlug: 'ultrasonic',\n error: otherError,\n tableName: 'ultrasonic_avail_country',\n }),\n ).toThrow(otherError)\n })\n})\n"],"names":["ValidationError","describe","expect","it","handleUpsertError","adapter","fieldConstraints","pgError","code","constraint","detail","thrown","collectionSlug","error","tableName","toBeInstanceOf","validationError","fieldError","data","errors","path","toBe","otherError","Error","toThrow"],"mappings":"AAAA,SAASA,eAAe,QAAQ,UAAS;AACzC,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAI7C,SAASC,iBAAiB,QAAQ,yBAAwB;AAE1D,MAAMC,UAAU;IAAEC,kBAAkB,CAAC;AAAE;AAEvCL,SAAS,qBAAqB;IAC5BE,GAAG,+DAA+D;QAChE,MAAMI,UAAU;YACdC,MAAM;YACNC,YAAY;YACZC,QAAQ;QACV;QAEA,IAAIC;QACJ,IAAI;YACFP,kBAAkB;gBAChBC;gBACAO,gBAAgB;gBAChBC,OAAON;gBACPO,WAAW;YACb;QACF,EAAE,OAAOD,OAAO;YACdF,SAASE;QACX;QAEAX,OAAOS,QAAQI,cAAc,CAACf;QAC9B,MAAMgB,kBAAkBL;QACxB,MAAMM,aAAaD,gBAAgBE,IAAI,CAACC,MAAM,CAAC,EAAE;QACjDjB,OAAOe,WAAWG,IAAI,EAAEC,IAAI,CAAC;QAC7BnB,OAAOe,WAAWH,SAAS,EAAEO,IAAI,CAAC;IACpC;IAEAlB,GAAG,oDAAoD;QACrD,MAAMmB,aAAa,IAAIC,MAAM;QAE7BrB,OAAO,IACLE,kBAAkB;gBAChBC;gBACAO,gBAAgB;gBAChBC,OAAOS;gBACPR,WAAW;YACb,IACAU,OAAO,CAACF;IACZ;AACF"}