@payloadcms/drizzle 4.0.0-internal.2f0d313 → 4.0.0-internal.314c594
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/postgres/init.d.ts.map +1 -1
- package/dist/postgres/init.js +6 -0
- package/dist/postgres/init.js.map +1 -1
- package/dist/queries/getTableColumnFromPath.d.ts +12 -3
- package/dist/queries/getTableColumnFromPath.d.ts.map +1 -1
- package/dist/queries/getTableColumnFromPath.js +50 -27
- package/dist/queries/getTableColumnFromPath.js.map +1 -1
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +151 -3
- package/dist/queries/parseParams.js.map +1 -1
- package/dist/queries/resolveRelationshipPath.d.ts +36 -0
- package/dist/queries/resolveRelationshipPath.d.ts.map +1 -0
- package/dist/queries/resolveRelationshipPath.js +66 -0
- package/dist/queries/resolveRelationshipPath.js.map +1 -0
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/build.js +4 -5
- package/dist/schema/build.js.map +1 -1
- package/dist/schema/buildRawSchema.spec.js +70 -10
- package/dist/schema/buildRawSchema.spec.js.map +1 -1
- package/dist/utilities/buildForeignKeyName.d.ts.map +1 -1
- package/dist/utilities/buildForeignKeyName.js +3 -2
- package/dist/utilities/buildForeignKeyName.js.map +1 -1
- package/dist/utilities/buildIndexName.d.ts.map +1 -1
- package/dist/utilities/buildIndexName.js +3 -2
- package/dist/utilities/buildIndexName.js.map +1 -1
- package/dist/utilities/checkTruncatedIdentifiers.d.ts +13 -0
- package/dist/utilities/checkTruncatedIdentifiers.d.ts.map +1 -0
- package/dist/utilities/checkTruncatedIdentifiers.js +56 -0
- package/dist/utilities/checkTruncatedIdentifiers.js.map +1 -0
- package/dist/utilities/checkTruncatedIdentifiers.spec.js +301 -0
- package/dist/utilities/checkTruncatedIdentifiers.spec.js.map +1 -0
- package/dist/utilities/validateIdentifierLength.d.ts +5 -0
- package/dist/utilities/validateIdentifierLength.d.ts.map +1 -1
- package/dist/utilities/validateIdentifierLength.js +4 -0
- package/dist/utilities/validateIdentifierLength.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { checkTruncatedIdentifiers } from './checkTruncatedIdentifiers.js';
|
|
3
|
+
import { maxIdentifierLength } from './validateIdentifierLength.js';
|
|
4
|
+
const buildAdapter = (rawTables, warn = ()=>{})=>({
|
|
5
|
+
payload: {
|
|
6
|
+
logger: {
|
|
7
|
+
warn
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
rawTables
|
|
11
|
+
});
|
|
12
|
+
const longName = (char)=>char.repeat(maxIdentifierLength + 1);
|
|
13
|
+
describe('checkTruncatedIdentifiers', ()=>{
|
|
14
|
+
it('should neither warn nor throw when all identifiers fit within the limit', ()=>{
|
|
15
|
+
const warn = vi.fn();
|
|
16
|
+
const adapter = buildAdapter({
|
|
17
|
+
posts: {
|
|
18
|
+
name: 'posts',
|
|
19
|
+
columns: {
|
|
20
|
+
id: {
|
|
21
|
+
name: 'id',
|
|
22
|
+
type: 'serial'
|
|
23
|
+
},
|
|
24
|
+
title: {
|
|
25
|
+
name: 'title',
|
|
26
|
+
type: 'text'
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}, warn);
|
|
31
|
+
expect(()=>checkTruncatedIdentifiers({
|
|
32
|
+
adapter,
|
|
33
|
+
logWarnings: true
|
|
34
|
+
})).not.toThrow();
|
|
35
|
+
expect(warn).not.toHaveBeenCalled();
|
|
36
|
+
});
|
|
37
|
+
it('should warn (not throw) for a single over-long column name', ()=>{
|
|
38
|
+
const columnName = longName('a');
|
|
39
|
+
const warn = vi.fn();
|
|
40
|
+
const adapter = buildAdapter({
|
|
41
|
+
posts: {
|
|
42
|
+
name: 'posts',
|
|
43
|
+
columns: {
|
|
44
|
+
overflow: {
|
|
45
|
+
name: columnName,
|
|
46
|
+
type: 'text'
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}, warn);
|
|
51
|
+
expect(()=>checkTruncatedIdentifiers({
|
|
52
|
+
adapter,
|
|
53
|
+
logWarnings: true
|
|
54
|
+
})).not.toThrow();
|
|
55
|
+
expect(warn).toHaveBeenCalledTimes(1);
|
|
56
|
+
expect(warn.mock.calls[0][0]).toContain(columnName);
|
|
57
|
+
});
|
|
58
|
+
it('should not warn when logWarnings is false', ()=>{
|
|
59
|
+
const warn = vi.fn();
|
|
60
|
+
const adapter = buildAdapter({
|
|
61
|
+
posts: {
|
|
62
|
+
name: 'posts',
|
|
63
|
+
columns: {
|
|
64
|
+
overflow: {
|
|
65
|
+
name: longName('a'),
|
|
66
|
+
type: 'text'
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}, warn);
|
|
71
|
+
expect(()=>checkTruncatedIdentifiers({
|
|
72
|
+
adapter,
|
|
73
|
+
logWarnings: false
|
|
74
|
+
})).not.toThrow();
|
|
75
|
+
expect(warn).not.toHaveBeenCalled();
|
|
76
|
+
});
|
|
77
|
+
it('should throw when two columns in the same table truncate to the same name', ()=>{
|
|
78
|
+
// Differ only past the 63rd character, so both truncate to the same identifier.
|
|
79
|
+
const shared = 'a'.repeat(maxIdentifierLength);
|
|
80
|
+
const adapter = buildAdapter({
|
|
81
|
+
posts: {
|
|
82
|
+
name: 'posts',
|
|
83
|
+
columns: {
|
|
84
|
+
first: {
|
|
85
|
+
name: `${shared}_one`,
|
|
86
|
+
type: 'text'
|
|
87
|
+
},
|
|
88
|
+
second: {
|
|
89
|
+
name: `${shared}_two`,
|
|
90
|
+
type: 'text'
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
expect(()=>checkTruncatedIdentifiers({
|
|
96
|
+
adapter,
|
|
97
|
+
logWarnings: true
|
|
98
|
+
})).toThrow('truncate to the same name');
|
|
99
|
+
});
|
|
100
|
+
it('should throw on a collision even when logWarnings is false', ()=>{
|
|
101
|
+
const shared = 'a'.repeat(maxIdentifierLength);
|
|
102
|
+
const adapter = buildAdapter({
|
|
103
|
+
posts: {
|
|
104
|
+
name: 'posts',
|
|
105
|
+
columns: {
|
|
106
|
+
first: {
|
|
107
|
+
name: `${shared}_one`,
|
|
108
|
+
type: 'text'
|
|
109
|
+
},
|
|
110
|
+
second: {
|
|
111
|
+
name: `${shared}_two`,
|
|
112
|
+
type: 'text'
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
expect(()=>checkTruncatedIdentifiers({
|
|
118
|
+
adapter,
|
|
119
|
+
logWarnings: false
|
|
120
|
+
})).toThrow();
|
|
121
|
+
});
|
|
122
|
+
it('should not treat same-named columns in different tables as a collision', ()=>{
|
|
123
|
+
const shared = 'a'.repeat(maxIdentifierLength);
|
|
124
|
+
const warn = vi.fn();
|
|
125
|
+
const adapter = buildAdapter({
|
|
126
|
+
posts: {
|
|
127
|
+
name: 'posts',
|
|
128
|
+
columns: {
|
|
129
|
+
overflow: {
|
|
130
|
+
name: `${shared}_one`,
|
|
131
|
+
type: 'text'
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
pages: {
|
|
136
|
+
name: 'pages',
|
|
137
|
+
columns: {
|
|
138
|
+
overflow: {
|
|
139
|
+
name: `${shared}_two`,
|
|
140
|
+
type: 'text'
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}, warn);
|
|
145
|
+
expect(()=>checkTruncatedIdentifiers({
|
|
146
|
+
adapter,
|
|
147
|
+
logWarnings: true
|
|
148
|
+
})).not.toThrow();
|
|
149
|
+
expect(warn).toHaveBeenCalledTimes(1);
|
|
150
|
+
});
|
|
151
|
+
it('should throw when two table names truncate to the same name', ()=>{
|
|
152
|
+
const shared = 'a'.repeat(maxIdentifierLength);
|
|
153
|
+
const adapter = buildAdapter({
|
|
154
|
+
[`${shared}_one`]: {
|
|
155
|
+
name: `${shared}_one`,
|
|
156
|
+
columns: {
|
|
157
|
+
id: {
|
|
158
|
+
name: 'id',
|
|
159
|
+
type: 'serial'
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
[`${shared}_two`]: {
|
|
164
|
+
name: `${shared}_two`,
|
|
165
|
+
columns: {
|
|
166
|
+
id: {
|
|
167
|
+
name: 'id',
|
|
168
|
+
type: 'serial'
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
expect(()=>checkTruncatedIdentifiers({
|
|
174
|
+
adapter,
|
|
175
|
+
logWarnings: true
|
|
176
|
+
})).toThrow('truncate to the same name');
|
|
177
|
+
});
|
|
178
|
+
it('should warn about a single over-long inline index name', ()=>{
|
|
179
|
+
const indexName = `${'a'.repeat(maxIdentifierLength)}_idx`;
|
|
180
|
+
const warn = vi.fn();
|
|
181
|
+
const adapter = buildAdapter({
|
|
182
|
+
posts: {
|
|
183
|
+
name: 'posts',
|
|
184
|
+
columns: {
|
|
185
|
+
id: {
|
|
186
|
+
name: 'id',
|
|
187
|
+
type: 'serial'
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
indexes: {
|
|
191
|
+
a: {
|
|
192
|
+
name: indexName,
|
|
193
|
+
on: 'id'
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}, warn);
|
|
198
|
+
checkTruncatedIdentifiers({
|
|
199
|
+
adapter,
|
|
200
|
+
logWarnings: true
|
|
201
|
+
});
|
|
202
|
+
expect(warn).toHaveBeenCalledTimes(1);
|
|
203
|
+
expect(warn.mock.calls[0][0]).toContain(indexName);
|
|
204
|
+
});
|
|
205
|
+
it('should throw when two inline index names truncate to the same name', ()=>{
|
|
206
|
+
const shared = 'a'.repeat(maxIdentifierLength);
|
|
207
|
+
const adapter = buildAdapter({
|
|
208
|
+
posts: {
|
|
209
|
+
name: 'posts',
|
|
210
|
+
columns: {
|
|
211
|
+
id: {
|
|
212
|
+
name: 'id',
|
|
213
|
+
type: 'serial'
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
indexes: {
|
|
217
|
+
a: {
|
|
218
|
+
name: `${shared}_one`,
|
|
219
|
+
on: 'id'
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
pages: {
|
|
224
|
+
name: 'pages',
|
|
225
|
+
columns: {
|
|
226
|
+
id: {
|
|
227
|
+
name: 'id',
|
|
228
|
+
type: 'serial'
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
indexes: {
|
|
232
|
+
b: {
|
|
233
|
+
name: `${shared}_two`,
|
|
234
|
+
on: 'id'
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
expect(()=>checkTruncatedIdentifiers({
|
|
240
|
+
adapter,
|
|
241
|
+
logWarnings: true
|
|
242
|
+
})).toThrow('truncate to the same name');
|
|
243
|
+
});
|
|
244
|
+
it('should throw when two inline foreign key names truncate to the same name', ()=>{
|
|
245
|
+
const shared = 'a'.repeat(maxIdentifierLength);
|
|
246
|
+
const adapter = buildAdapter({
|
|
247
|
+
posts: {
|
|
248
|
+
name: 'posts',
|
|
249
|
+
columns: {
|
|
250
|
+
author_id: {
|
|
251
|
+
name: 'author_id',
|
|
252
|
+
type: 'integer'
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
foreignKeys: {
|
|
256
|
+
a: {
|
|
257
|
+
name: `${shared}_one`,
|
|
258
|
+
columns: [
|
|
259
|
+
'author_id'
|
|
260
|
+
],
|
|
261
|
+
foreignColumns: [
|
|
262
|
+
{
|
|
263
|
+
name: 'id',
|
|
264
|
+
table: 'authors'
|
|
265
|
+
}
|
|
266
|
+
]
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
pages: {
|
|
271
|
+
name: 'pages',
|
|
272
|
+
columns: {
|
|
273
|
+
author_id: {
|
|
274
|
+
name: 'author_id',
|
|
275
|
+
type: 'integer'
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
foreignKeys: {
|
|
279
|
+
b: {
|
|
280
|
+
name: `${shared}_two`,
|
|
281
|
+
columns: [
|
|
282
|
+
'author_id'
|
|
283
|
+
],
|
|
284
|
+
foreignColumns: [
|
|
285
|
+
{
|
|
286
|
+
name: 'id',
|
|
287
|
+
table: 'authors'
|
|
288
|
+
}
|
|
289
|
+
]
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
expect(()=>checkTruncatedIdentifiers({
|
|
295
|
+
adapter,
|
|
296
|
+
logWarnings: true
|
|
297
|
+
})).toThrow('truncate to the same name');
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
//# sourceMappingURL=checkTruncatedIdentifiers.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/checkTruncatedIdentifiers.spec.ts"],"sourcesContent":["import { describe, expect, it, vi } from 'vitest'\n\nimport type { DrizzleAdapter } from '../types.js'\n\nimport { checkTruncatedIdentifiers } from './checkTruncatedIdentifiers.js'\nimport { maxIdentifierLength } from './validateIdentifierLength.js'\n\nconst buildAdapter = (\n rawTables: DrizzleAdapter['rawTables'],\n warn: (...args: any[]) => void = () => {},\n): Pick<DrizzleAdapter, 'payload' | 'rawTables'> =>\n ({\n payload: { logger: { warn } },\n rawTables,\n }) as unknown as Pick<DrizzleAdapter, 'payload' | 'rawTables'>\n\nconst longName = (char: string) => char.repeat(maxIdentifierLength + 1)\n\ndescribe('checkTruncatedIdentifiers', () => {\n it('should neither warn nor throw when all identifiers fit within the limit', () => {\n const warn = vi.fn()\n\n const adapter = buildAdapter(\n {\n posts: {\n name: 'posts',\n columns: {\n id: { name: 'id', type: 'serial' },\n title: { name: 'title', type: 'text' },\n },\n },\n },\n warn,\n )\n\n expect(() => checkTruncatedIdentifiers({ adapter, logWarnings: true })).not.toThrow()\n expect(warn).not.toHaveBeenCalled()\n })\n\n it('should warn (not throw) for a single over-long column name', () => {\n const columnName = longName('a')\n const warn = vi.fn()\n\n const adapter = buildAdapter(\n {\n posts: {\n name: 'posts',\n columns: {\n overflow: { name: columnName, type: 'text' },\n },\n },\n },\n warn,\n )\n\n expect(() => checkTruncatedIdentifiers({ adapter, logWarnings: true })).not.toThrow()\n expect(warn).toHaveBeenCalledTimes(1)\n expect(warn.mock.calls[0][0]).toContain(columnName)\n })\n\n it('should not warn when logWarnings is false', () => {\n const warn = vi.fn()\n\n const adapter = buildAdapter(\n {\n posts: {\n name: 'posts',\n columns: {\n overflow: { name: longName('a'), type: 'text' },\n },\n },\n },\n warn,\n )\n\n expect(() => checkTruncatedIdentifiers({ adapter, logWarnings: false })).not.toThrow()\n expect(warn).not.toHaveBeenCalled()\n })\n\n it('should throw when two columns in the same table truncate to the same name', () => {\n // Differ only past the 63rd character, so both truncate to the same identifier.\n const shared = 'a'.repeat(maxIdentifierLength)\n\n const adapter = buildAdapter({\n posts: {\n name: 'posts',\n columns: {\n first: { name: `${shared}_one`, type: 'text' },\n second: { name: `${shared}_two`, type: 'text' },\n },\n },\n })\n\n expect(() => checkTruncatedIdentifiers({ adapter, logWarnings: true })).toThrow(\n 'truncate to the same name',\n )\n })\n\n it('should throw on a collision even when logWarnings is false', () => {\n const shared = 'a'.repeat(maxIdentifierLength)\n\n const adapter = buildAdapter({\n posts: {\n name: 'posts',\n columns: {\n first: { name: `${shared}_one`, type: 'text' },\n second: { name: `${shared}_two`, type: 'text' },\n },\n },\n })\n\n expect(() => checkTruncatedIdentifiers({ adapter, logWarnings: false })).toThrow()\n })\n\n it('should not treat same-named columns in different tables as a collision', () => {\n const shared = 'a'.repeat(maxIdentifierLength)\n const warn = vi.fn()\n\n const adapter = buildAdapter(\n {\n posts: {\n name: 'posts',\n columns: {\n overflow: { name: `${shared}_one`, type: 'text' },\n },\n },\n pages: {\n name: 'pages',\n columns: {\n overflow: { name: `${shared}_two`, type: 'text' },\n },\n },\n },\n warn,\n )\n\n expect(() => checkTruncatedIdentifiers({ adapter, logWarnings: true })).not.toThrow()\n expect(warn).toHaveBeenCalledTimes(1)\n })\n\n it('should throw when two table names truncate to the same name', () => {\n const shared = 'a'.repeat(maxIdentifierLength)\n\n const adapter = buildAdapter({\n [`${shared}_one`]: {\n name: `${shared}_one`,\n columns: { id: { name: 'id', type: 'serial' } },\n },\n [`${shared}_two`]: {\n name: `${shared}_two`,\n columns: { id: { name: 'id', type: 'serial' } },\n },\n })\n\n expect(() => checkTruncatedIdentifiers({ adapter, logWarnings: true })).toThrow(\n 'truncate to the same name',\n )\n })\n\n it('should warn about a single over-long inline index name', () => {\n const indexName = `${'a'.repeat(maxIdentifierLength)}_idx`\n const warn = vi.fn()\n\n const adapter = buildAdapter(\n {\n posts: {\n name: 'posts',\n columns: { id: { name: 'id', type: 'serial' } },\n indexes: { a: { name: indexName, on: 'id' } },\n },\n },\n warn,\n )\n\n checkTruncatedIdentifiers({ adapter, logWarnings: true })\n\n expect(warn).toHaveBeenCalledTimes(1)\n expect(warn.mock.calls[0][0]).toContain(indexName)\n })\n\n it('should throw when two inline index names truncate to the same name', () => {\n const shared = 'a'.repeat(maxIdentifierLength)\n\n const adapter = buildAdapter({\n posts: {\n name: 'posts',\n columns: { id: { name: 'id', type: 'serial' } },\n indexes: { a: { name: `${shared}_one`, on: 'id' } },\n },\n pages: {\n name: 'pages',\n columns: { id: { name: 'id', type: 'serial' } },\n indexes: { b: { name: `${shared}_two`, on: 'id' } },\n },\n })\n\n expect(() => checkTruncatedIdentifiers({ adapter, logWarnings: true })).toThrow(\n 'truncate to the same name',\n )\n })\n\n it('should throw when two inline foreign key names truncate to the same name', () => {\n const shared = 'a'.repeat(maxIdentifierLength)\n\n const adapter = buildAdapter({\n posts: {\n name: 'posts',\n columns: { author_id: { name: 'author_id', type: 'integer' } },\n foreignKeys: {\n a: {\n name: `${shared}_one`,\n columns: ['author_id'],\n foreignColumns: [{ name: 'id', table: 'authors' }],\n },\n },\n },\n pages: {\n name: 'pages',\n columns: { author_id: { name: 'author_id', type: 'integer' } },\n foreignKeys: {\n b: {\n name: `${shared}_two`,\n columns: ['author_id'],\n foreignColumns: [{ name: 'id', table: 'authors' }],\n },\n },\n },\n })\n\n expect(() => checkTruncatedIdentifiers({ adapter, logWarnings: true })).toThrow(\n 'truncate to the same name',\n )\n })\n})\n"],"names":["describe","expect","it","vi","checkTruncatedIdentifiers","maxIdentifierLength","buildAdapter","rawTables","warn","payload","logger","longName","char","repeat","fn","adapter","posts","name","columns","id","type","title","logWarnings","not","toThrow","toHaveBeenCalled","columnName","overflow","toHaveBeenCalledTimes","mock","calls","toContain","shared","first","second","pages","indexName","indexes","a","on","b","author_id","foreignKeys","foreignColumns","table"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,SAAQ;AAIjD,SAASC,yBAAyB,QAAQ,iCAAgC;AAC1E,SAASC,mBAAmB,QAAQ,gCAA+B;AAEnE,MAAMC,eAAe,CACnBC,WACAC,OAAiC,KAAO,CAAC,GAExC,CAAA;QACCC,SAAS;YAAEC,QAAQ;gBAAEF;YAAK;QAAE;QAC5BD;IACF,CAAA;AAEF,MAAMI,WAAW,CAACC,OAAiBA,KAAKC,MAAM,CAACR,sBAAsB;AAErEL,SAAS,6BAA6B;IACpCE,GAAG,2EAA2E;QAC5E,MAAMM,OAAOL,GAAGW,EAAE;QAElB,MAAMC,UAAUT,aACd;YACEU,OAAO;gBACLC,MAAM;gBACNC,SAAS;oBACPC,IAAI;wBAAEF,MAAM;wBAAMG,MAAM;oBAAS;oBACjCC,OAAO;wBAAEJ,MAAM;wBAASG,MAAM;oBAAO;gBACvC;YACF;QACF,GACAZ;QAGFP,OAAO,IAAMG,0BAA0B;gBAAEW;gBAASO,aAAa;YAAK,IAAIC,GAAG,CAACC,OAAO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AA0B;gBAAEW;gBAASO,aAAa;YAAK,IAAIE,OAAO,CAC7E;IAEJ;IAEAtB,GAAG,4EAA4E;QAC7E,MAAM8B,SAAS,IAAInB,MAAM,CAACR;QAE1B,MAAMU,UAAUT,aAAa;YAC3BU,OAAO;gBACLC,MAAM;gBACNC,SAAS;oBAAEuB,WAAW;wBAAExB,MAAM;wBAAaG,MAAM;oBAAU;gBAAE;gBAC7DsB,aAAa;oBACXJ,GAAG;wBACDrB,MAAM,GAAGe,OAAO,IAAI,CAAC;wBACrBd,SAAS;4BAAC;yBAAY;wBACtByB,gBAAgB;4BAAC;gCAAE1B,MAAM;gCAAM2B,OAAO;4BAAU;yBAAE;oBACpD;gBACF;YACF;YACAT,OAAO;gBACLlB,MAAM;gBACNC,SAAS;oBAAEuB,WAAW;wBAAExB,MAAM;wBAAaG,MAAM;oBAAU;gBAAE;gBAC7DsB,aAAa;oBACXF,GAAG;wBACDvB,MAAM,GAAGe,OAAO,IAAI,CAAC;wBACrBd,SAAS;4BAAC;yBAAY;wBACtByB,gBAAgB;4BAAC;gCAAE1B,MAAM;gCAAM2B,OAAO;4BAAU;yBAAE;oBACpD;gBACF;YACF;QACF;QAEA3C,OAAO,IAAMG,0BAA0B;gBAAEW;gBAASO,aAAa;YAAK,IAAIE,OAAO,CAC7E;IAEJ;AACF"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/** Postgres max identifier length (NAMEDATALEN - 1). */
|
|
2
2
|
export declare const maxIdentifierLength = 63;
|
|
3
|
+
/**
|
|
4
|
+
* Cap for builder-generated identifiers (`buildIndexName`/`buildForeignKeyName`). Sits
|
|
5
|
+
* below `maxIdentifierLength` to leave headroom for the appended `_idx`/`_fk`/`_N` suffixes.
|
|
6
|
+
*/
|
|
7
|
+
export declare const maxGeneratedIdentifierLength: number;
|
|
3
8
|
/**
|
|
4
9
|
* Throws if a table or enum identifier exceeds the Postgres 63-char limit.
|
|
5
10
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateIdentifierLength.d.ts","sourceRoot":"","sources":["../../src/utilities/validateIdentifierLength.ts"],"names":[],"mappings":"AAEA,wDAAwD;AACxD,eAAO,MAAM,mBAAmB,KAAK,CAAA;AAErC;;GAEG;AACH,eAAO,MAAM,wBAAwB,SAAU,MAAM,KAAG,MAUvD,CAAA"}
|
|
1
|
+
{"version":3,"file":"validateIdentifierLength.d.ts","sourceRoot":"","sources":["../../src/utilities/validateIdentifierLength.ts"],"names":[],"mappings":"AAEA,wDAAwD;AACxD,eAAO,MAAM,mBAAmB,KAAK,CAAA;AAErC;;;GAGG;AACH,eAAO,MAAM,4BAA4B,QAA0B,CAAA;AAEnE;;GAEG;AACH,eAAO,MAAM,wBAAwB,SAAU,MAAM,KAAG,MAUvD,CAAA"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { APIError } from 'payload';
|
|
2
2
|
/** Postgres max identifier length (NAMEDATALEN - 1). */ export const maxIdentifierLength = 63;
|
|
3
|
+
/**
|
|
4
|
+
* Cap for builder-generated identifiers (`buildIndexName`/`buildForeignKeyName`). Sits
|
|
5
|
+
* below `maxIdentifierLength` to leave headroom for the appended `_idx`/`_fk`/`_N` suffixes.
|
|
6
|
+
*/ export const maxGeneratedIdentifierLength = maxIdentifierLength - 3;
|
|
3
7
|
/**
|
|
4
8
|
* Throws if a table or enum identifier exceeds the Postgres 63-char limit.
|
|
5
9
|
*/ export const validateIdentifierLength = (name)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/validateIdentifierLength.ts"],"sourcesContent":["import { APIError } from 'payload'\n\n/** Postgres max identifier length (NAMEDATALEN - 1). */\nexport const maxIdentifierLength = 63\n\n/**\n * Throws if a table or enum identifier exceeds the Postgres 63-char limit.\n */\nexport const validateIdentifierLength = (name: string): string => {\n if (name.length > maxIdentifierLength) {\n throw new APIError(\n `Exceeded max identifier length for table or enum name of ${maxIdentifierLength} characters. Invalid name: ${name}.\nTip: You can use the dbName property to reduce the table name length.\n `,\n )\n }\n\n return name\n}\n"],"names":["APIError","maxIdentifierLength","validateIdentifierLength","name","length"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,UAAS;AAElC,sDAAsD,GACtD,OAAO,MAAMC,sBAAsB,GAAE;AAErC;;CAEC,GACD,OAAO,
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/validateIdentifierLength.ts"],"sourcesContent":["import { APIError } from 'payload'\n\n/** Postgres max identifier length (NAMEDATALEN - 1). */\nexport const maxIdentifierLength = 63\n\n/**\n * Cap for builder-generated identifiers (`buildIndexName`/`buildForeignKeyName`). Sits\n * below `maxIdentifierLength` to leave headroom for the appended `_idx`/`_fk`/`_N` suffixes.\n */\nexport const maxGeneratedIdentifierLength = maxIdentifierLength - 3\n\n/**\n * Throws if a table or enum identifier exceeds the Postgres 63-char limit.\n */\nexport const validateIdentifierLength = (name: string): string => {\n if (name.length > maxIdentifierLength) {\n throw new APIError(\n `Exceeded max identifier length for table or enum name of ${maxIdentifierLength} characters. Invalid name: ${name}.\nTip: You can use the dbName property to reduce the table name length.\n `,\n )\n }\n\n return name\n}\n"],"names":["APIError","maxIdentifierLength","maxGeneratedIdentifierLength","validateIdentifierLength","name","length"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,UAAS;AAElC,sDAAsD,GACtD,OAAO,MAAMC,sBAAsB,GAAE;AAErC;;;CAGC,GACD,OAAO,MAAMC,+BAA+BD,sBAAsB,EAAC;AAEnE;;CAEC,GACD,OAAO,MAAME,2BAA2B,CAACC;IACvC,IAAIA,KAAKC,MAAM,GAAGJ,qBAAqB;QACrC,MAAM,IAAID,SACR,CAAC,yDAAyD,EAAEC,oBAAoB,2BAA2B,EAAEG,KAAK;;MAElH,CAAC;IAEL;IAEA,OAAOA;AACT,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/drizzle",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.314c594",
|
|
4
4
|
"description": "A library of shared functions used by different payload database adapters",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"@types/pg": "8.20.0",
|
|
56
56
|
"@types/to-snake-case": "1.0.0",
|
|
57
57
|
"@payloadcms/eslint-config": "3.28.0",
|
|
58
|
-
"payload": "4.0.0-internal.
|
|
58
|
+
"payload": "4.0.0-internal.314c594"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"payload": "4.0.0-internal.
|
|
61
|
+
"payload": "4.0.0-internal.314c594"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "pnpm build:swc && pnpm build:types",
|