@payloadcms/drizzle 4.0.0-internal.2fddfc0 → 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/LICENSE.md +1 -1
- package/dist/createTableName.d.ts.map +1 -1
- package/dist/createTableName.js +2 -7
- package/dist/createTableName.js.map +1 -1
- package/dist/exports/postgres.d.ts +2 -0
- package/dist/exports/postgres.d.ts.map +1 -1
- package/dist/exports/postgres.js +2 -0
- package/dist/exports/postgres.js.map +1 -1
- package/dist/find/buildFindManyArgs.d.ts.map +1 -1
- package/dist/find/findMany.d.ts.map +1 -1
- package/dist/find/traverseFields.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/postgres/createDatabase.d.ts.map +1 -1
- package/dist/postgres/createExtensions.d.ts.map +1 -1
- package/dist/postgres/createJSONQuery/index.d.ts.map +1 -1
- 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/postgres/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/index.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -1
- package/dist/postgres/query/assertOperatorHandlerExtensionsInstalled.d.ts +15 -0
- package/dist/postgres/query/assertOperatorHandlerExtensionsInstalled.d.ts.map +1 -0
- package/dist/postgres/query/assertOperatorHandlerExtensionsInstalled.js +25 -0
- package/dist/postgres/query/assertOperatorHandlerExtensionsInstalled.js.map +1 -0
- package/dist/postgres/query/assertOperatorHandlerExtensionsInstalled.spec.js +91 -0
- package/dist/postgres/query/assertOperatorHandlerExtensionsInstalled.spec.js.map +1 -0
- package/dist/postgres/query/postgresUnaccent.d.ts +13 -0
- package/dist/postgres/query/postgresUnaccent.d.ts.map +1 -0
- package/dist/postgres/query/postgresUnaccent.js +40 -0
- package/dist/postgres/query/postgresUnaccent.js.map +1 -0
- package/dist/postgres/query/postgresUnaccent.spec.js +71 -0
- package/dist/postgres/query/postgresUnaccent.spec.js.map +1 -0
- package/dist/postgres/schema/buildDrizzleTable.d.ts.map +1 -1
- package/dist/postgres/schema/geometryColumn.d.ts +2 -2
- package/dist/postgres/schema/geometryColumn.d.ts.map +1 -1
- package/dist/postgres/types.d.ts +13 -2
- package/dist/postgres/types.d.ts.map +1 -1
- package/dist/postgres/types.js.map +1 -1
- package/dist/queries/addJoinTable.d.ts +1 -1
- package/dist/queries/addJoinTable.d.ts.map +1 -1
- package/dist/queries/buildOperatorConstraint.d.ts +22 -0
- package/dist/queries/buildOperatorConstraint.d.ts.map +1 -0
- package/dist/queries/buildOperatorConstraint.js +63 -0
- package/dist/queries/buildOperatorConstraint.js.map +1 -0
- package/dist/queries/buildOperatorConstraint.spec.js +348 -0
- package/dist/queries/buildOperatorConstraint.spec.js.map +1 -0
- package/dist/queries/buildOrderBy.d.ts +1 -1
- package/dist/queries/buildOrderBy.d.ts.map +1 -1
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/getTableAlias.d.ts.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/operatorMap.d.ts +7 -3
- package/dist/queries/operatorMap.d.ts.map +1 -1
- package/dist/queries/operatorMap.js.map +1 -1
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +203 -8
- 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/queries/sanitizeQueryValue.d.ts.map +1 -1
- package/dist/queries/selectDistinct.d.ts.map +1 -1
- package/dist/queries/validateOperatorHandlers.d.ts +8 -0
- package/dist/queries/validateOperatorHandlers.d.ts.map +1 -0
- package/dist/queries/validateOperatorHandlers.js +30 -0
- package/dist/queries/validateOperatorHandlers.js.map +1 -0
- package/dist/queries/validateOperatorHandlers.spec.js +142 -0
- package/dist/queries/validateOperatorHandlers.spec.js.map +1 -0
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/buildDrizzleRelations.d.ts.map +1 -1
- package/dist/schema/buildRawSchema.d.ts.map +1 -1
- package/dist/schema/buildRawSchema.spec.js +290 -0
- package/dist/schema/buildRawSchema.spec.js.map +1 -0
- package/dist/schema/idToUUID.d.ts.map +1 -1
- package/dist/schema/traverseFields.d.ts.map +1 -1
- package/dist/schema/traverseFields.js +6 -5
- package/dist/schema/traverseFields.js.map +1 -1
- package/dist/schema/withDefault.d.ts.map +1 -1
- package/dist/sqlite/createJSONQuery/convertPathToJSONTraversal.d.ts.map +1 -1
- package/dist/sqlite/createJSONQuery/index.d.ts.map +1 -1
- package/dist/transform/read/hasManyNumber.d.ts.map +1 -1
- package/dist/transform/read/hasManyText.d.ts.map +1 -1
- package/dist/transform/read/index.d.ts.map +1 -1
- package/dist/transform/read/relationship.d.ts.map +1 -1
- package/dist/transform/read/traverseFields.d.ts.map +1 -1
- package/dist/transform/write/array.d.ts.map +1 -1
- package/dist/transform/write/blocks.d.ts.map +1 -1
- package/dist/transform/write/index.d.ts.map +1 -1
- package/dist/transform/write/numbers.d.ts.map +1 -1
- package/dist/transform/write/relationships.d.ts.map +1 -1
- package/dist/transform/write/selects.d.ts.map +1 -1
- package/dist/transform/write/texts.d.ts.map +1 -1
- package/dist/transform/write/traverseFields.d.ts.map +1 -1
- package/dist/types.d.ts +50 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -3
- package/dist/types.js.map +1 -1
- package/dist/updateJobs.d.ts.map +1 -1
- package/dist/updateJobs.js +37 -0
- package/dist/updateJobs.js.map +1 -1
- package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +1 -1
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +1 -1
- package/dist/upsertRow/handleUpsertError.d.ts.map +1 -1
- package/dist/upsertRow/index.d.ts.map +1 -1
- package/dist/upsertRow/insertArrays.d.ts.map +1 -1
- package/dist/upsertRow/insertArrays.js +2 -1
- package/dist/upsertRow/insertArrays.js.map +1 -1
- package/dist/upsertRow/shouldUseOptimizedUpsertRow.d.ts.map +1 -1
- package/dist/utilities/appendPrefixToKeys.d.ts.map +1 -1
- package/dist/utilities/blocksToJsonMigrator.d.ts.map +1 -1
- package/dist/utilities/buildCreateMigration.d.ts.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/createBlocksMap.d.ts.map +1 -1
- package/dist/utilities/createRelationshipMap.d.ts.map +1 -1
- package/dist/utilities/createSchemaGenerator.d.ts.map +1 -1
- package/dist/utilities/escapeSQLValue.d.ts.map +1 -1
- package/dist/utilities/executeSchemaHooks.d.ts.map +1 -1
- package/dist/utilities/extendDrizzleTable.d.ts.map +1 -1
- package/dist/utilities/getArrayRelationName.d.ts.map +1 -1
- package/dist/utilities/getCollectionIdType.d.ts.map +1 -1
- package/dist/utilities/getMigrationTemplate.d.ts.map +1 -1
- package/dist/utilities/getNameFromDrizzleTable.d.ts.map +1 -1
- package/dist/utilities/getPrimaryDb.d.ts +1 -1
- package/dist/utilities/getPrimaryDb.d.ts.map +1 -1
- package/dist/utilities/getTransaction.d.ts +1 -1
- package/dist/utilities/getTransaction.d.ts.map +1 -1
- package/dist/utilities/hasLocalesTable.d.ts.map +1 -1
- package/dist/utilities/isPolymorphicRelationship.d.ts.map +1 -1
- package/dist/utilities/isUUIDType.d.ts.map +1 -1
- package/dist/utilities/json.d.ts.map +1 -1
- package/dist/utilities/migrationTableExists.d.ts.map +1 -1
- package/dist/utilities/parseError.d.ts.map +1 -1
- package/dist/utilities/pushDevSchema.d.ts.map +1 -1
- package/dist/utilities/rawConstraint.d.ts.map +1 -1
- package/dist/utilities/sanitizePathSegment.d.ts.map +1 -1
- package/dist/utilities/validateExistingBlockIsIdentical.d.ts +1 -5
- package/dist/utilities/validateExistingBlockIsIdentical.d.ts.map +1 -1
- package/dist/utilities/validateExistingBlockIsIdentical.js.map +1 -1
- package/dist/utilities/validateIdentifierLength.d.ts +12 -0
- package/dist/utilities/validateIdentifierLength.d.ts.map +1 -0
- package/dist/utilities/validateIdentifierLength.js +18 -0
- package/dist/utilities/validateIdentifierLength.js.map +1 -0
- package/dist/utilities/validateIdentifierLength.spec.js +19 -0
- package/dist/utilities/validateIdentifierLength.spec.js.map +1 -0
- package/package.json +4 -4
- package/dist/find/chainMethods.d.ts +0 -20
- package/dist/find/chainMethods.d.ts.map +0 -1
- package/dist/find/chainMethods.js +0 -16
- package/dist/find/chainMethods.js.map +0 -1
|
@@ -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;QACnFvB,OAAOO,MAAMe,GAAG,CAACE,gBAAgB;IACnC;IAEAvB,GAAG,8DAA8D;QAC/D,MAAMwB,aAAaf,SAAS;QAC5B,MAAMH,OAAOL,GAAGW,EAAE;QAElB,MAAMC,UAAUT,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BU,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBlocksMap.d.ts","sourceRoot":"","sources":["../../src/utilities/createBlocksMap.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CAC1C,CAAA;AAED,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"createBlocksMap.d.ts","sourceRoot":"","sources":["../../src/utilities/createBlocksMap.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CAC1C,CAAA;AAED,eAAO,MAAM,eAAe,SAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,SAyC/D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRelationshipMap.d.ts","sourceRoot":"","sources":["../../src/utilities/createRelationshipMap.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"createRelationshipMap.d.ts","sourceRoot":"","sources":["../../src/utilities/createRelationshipMap.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,SAAU,OAAO,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAqBrF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSchemaGenerator.d.ts","sourceRoot":"","sources":["../../src/utilities/createSchemaGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAM7C,OAAO,KAAK,EAAE,qBAAqB,EAAkB,MAAM,aAAa,CAAA;AAkCxE,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"createSchemaGenerator.d.ts","sourceRoot":"","sources":["../../src/utilities/createSchemaGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAM7C,OAAO,KAAK,EAAE,qBAAqB,EAAkB,MAAM,aAAa,CAAA;AAkCxE,eAAO,MAAM,qBAAqB,4GAO/B;IACD,qBAAqB,EAAE,qBAAqB,CAAA;IAC5C,iBAAiB,EAAE,MAAM,CAAA;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;CACpB,KAAG,cAiTH,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escapeSQLValue.d.ts","sourceRoot":"","sources":["../../src/utilities/escapeSQLValue.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,QAAmB,CAAA;AAEjD,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"escapeSQLValue.d.ts","sourceRoot":"","sources":["../../src/utilities/escapeSQLValue.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,QAAmB,CAAA;AAEjD,eAAO,MAAM,cAAc,UAAW,OAAO,KAAG,OAAO,GAAG,IAAI,GAAG,MAAM,GAAG,MAoBzE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeSchemaHooks.d.ts","sourceRoot":"","sources":["../../src/utilities/executeSchemaHooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D,KAAK,cAAc,GAAG;IACpB,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAA;IAC/B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC9B,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAA;CACjC,CAAA;AAED,KAAK,OAAO,GAAG;IACb,eAAe,EAAE,kBAAkB,EAAE,CAAA;IACrC,gBAAgB,EAAE,kBAAkB,EAAE,CAAA;CACvC,GAAG,cAAc,CAAA;AAElB,KAAK,sBAAsB,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,WAAW,EAAE,OAAO,kBAAkB,CAAA;IACtC,MAAM,EAAE,cAAc,CAAA;CACvB,CAAA;AAED,KAAK,kBAAkB,GAAG,CAAC,IAAI,EAAE,sBAAsB,KAAK,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;AAEpG,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,iBAAiB,GAAG,kBAAkB,CAAA;CAC7C,CAAA;AAED,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"executeSchemaHooks.d.ts","sourceRoot":"","sources":["../../src/utilities/executeSchemaHooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D,KAAK,cAAc,GAAG;IACpB,KAAK,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAA;IAC/B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC9B,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAA;CACjC,CAAA;AAED,KAAK,OAAO,GAAG;IACb,eAAe,EAAE,kBAAkB,EAAE,CAAA;IACrC,gBAAgB,EAAE,kBAAkB,EAAE,CAAA;CACvC,GAAG,cAAc,CAAA;AAElB,KAAK,sBAAsB,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,WAAW,EAAE,OAAO,kBAAkB,CAAA;IACtC,MAAM,EAAE,cAAc,CAAA;CACvB,CAAA;AAED,KAAK,kBAAkB,GAAG,CAAC,IAAI,EAAE,sBAAsB,KAAK,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;AAEpG,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,iBAAiB,GAAG,kBAAkB,CAAA;CAC7C,CAAA;AAED,eAAO,MAAM,kBAAkB,sBAA6B,IAAI,KAAG,OAAO,CAAC,IAAI,CAkB9E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extendDrizzleTable.d.ts","sourceRoot":"","sources":["../../src/utilities/extendDrizzleTable.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAWnC,KAAK,IAAI,GAAG;IACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAA;IAChD,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAA;IACnD,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"extendDrizzleTable.d.ts","sourceRoot":"","sources":["../../src/utilities/extendDrizzleTable.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAWnC,KAAK,IAAI,GAAG;IACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAA;IAChD,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAA;IACnD,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,oCAAqC,IAAI,KAAG,IAkC1E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getArrayRelationName.d.ts","sourceRoot":"","sources":["../../src/utilities/getArrayRelationName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"getArrayRelationName.d.ts","sourceRoot":"","sources":["../../src/utilities/getArrayRelationName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,eAAO,MAAM,oBAAoB,gCAI9B;IACD,KAAK,EAAE,UAAU,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;CAClB,WAMA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCollectionIdType.d.ts","sourceRoot":"","sources":["../../src/utilities/getCollectionIdType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAUjD,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"getCollectionIdType.d.ts","sourceRoot":"","sources":["../../src/utilities/getCollectionIdType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAUjD,eAAO,MAAM,mBAAmB,6BAG7B;IACD,OAAO,EAAE,cAAc,CAAA;IACvB,UAAU,EAAE,UAAU,CAAA;CACvB,sBAEA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMigrationTemplate.d.ts","sourceRoot":"","sources":["../../src/utilities/getMigrationTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"getMigrationTemplate.d.ts","sourceRoot":"","sources":["../../src/utilities/getMigrationTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,eAAO,MAAM,MAAM,SAAU,MAAM,WAIpB,CAAA;AAEf,eAAO,MAAM,oBAAoB,8CAK9B,qBAAqB,KAAG,MAS1B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNameFromDrizzleTable.d.ts","sourceRoot":"","sources":["../../src/utilities/getNameFromDrizzleTable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAIxC,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"getNameFromDrizzleTable.d.ts","sourceRoot":"","sources":["../../src/utilities/getNameFromDrizzleTable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAIxC,eAAO,MAAM,uBAAuB,UAAW,KAAK,KAAG,MAEtD,CAAA"}
|
|
@@ -2,5 +2,5 @@ import type { DrizzleAdapter, DrizzleTransaction } from '../types.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Returns the correct database instance for reads that are part of a write operation.
|
|
4
4
|
*/
|
|
5
|
-
export declare const getPrimaryDb: (adapter: DrizzleAdapter, db: DrizzleAdapter[
|
|
5
|
+
export declare const getPrimaryDb: (adapter: DrizzleAdapter, db: DrizzleAdapter['drizzle'] | DrizzleTransaction) => import("drizzle-orm/libsql").LibSQLDatabase<Record<string, never>> | import("../types.js").PostgresDB | DrizzleTransaction;
|
|
6
6
|
//# sourceMappingURL=getPrimaryDb.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPrimaryDb.d.ts","sourceRoot":"","sources":["../../src/utilities/getPrimaryDb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErE;;GAEG;AACH,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"getPrimaryDb.d.ts","sourceRoot":"","sources":["../../src/utilities/getPrimaryDb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErE;;GAEG;AACH,eAAO,MAAM,YAAY,YACd,cAAc,MACnB,cAAc,CAAC,SAAS,CAAC,GAAG,kBAAkB,+HAMnD,CAAA"}
|
|
@@ -9,5 +9,5 @@ import type { DrizzleAdapter } from '../types.js';
|
|
|
9
9
|
* When read replicas are configured and a write happened recently, returns the
|
|
10
10
|
* unwrapped primary to avoid replication-lag stale reads.
|
|
11
11
|
*/
|
|
12
|
-
export declare const getTransaction: <T extends DrizzleAdapter = DrizzleAdapter>(adapter: T, req?: Partial<PayloadRequest>) => Promise<T[
|
|
12
|
+
export declare const getTransaction: <T extends DrizzleAdapter = DrizzleAdapter>(adapter: T, req?: Partial<PayloadRequest>) => Promise<T['drizzle']>;
|
|
13
13
|
//# sourceMappingURL=getTransaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTransaction.d.ts","sourceRoot":"","sources":["../../src/utilities/getTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAU,CAAC,SAAS,cAAc,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"getTransaction.d.ts","sourceRoot":"","sources":["../../src/utilities/getTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAU,CAAC,SAAS,cAAc,GAAG,cAAc,WACnE,CAAC,QACJ,OAAO,CAAC,cAAc,CAAC,KAC5B,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAStB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasLocalesTable.d.ts","sourceRoot":"","sources":["../../src/utilities/hasLocalesTable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAIpC,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"hasLocalesTable.d.ts","sourceRoot":"","sources":["../../src/utilities/hasLocalesTable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAIpC,eAAO,MAAM,eAAe,mCAGzB;IACD,MAAM,EAAE,KAAK,EAAE,CAAA;IACf;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B,KAAG,OAyBH,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isPolymorphicRelationship.d.ts","sourceRoot":"","sources":["../../src/utilities/isPolymorphicRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,eAAO,MAAM,yBAAyB,
|
|
1
|
+
{"version":3,"file":"isPolymorphicRelationship.d.ts","sourceRoot":"","sources":["../../src/utilities/isPolymorphicRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,eAAO,MAAM,yBAAyB,UAC7B,OAAO,KACb,KAAK,IAAI;IACV,UAAU,EAAE,cAAc,CAAA;IAC1B,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CASvB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUUIDType.d.ts","sourceRoot":"","sources":["../../src/utilities/isUUIDType.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"isUUIDType.d.ts","sourceRoot":"","sources":["../../src/utilities/isUUIDType.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,WAAY,MAAM,KAAG,OAAmD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/utilities/json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAK9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,gBAM/D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,EACpE,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,CAAC,gBAuBT;AAED,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/utilities/json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAK9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,gBAM/D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,EACpE,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,CAAC,gBAuBT;AAED,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,WAC9D,cAAc,SAChB,CAAC,iBAGT,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrationTableExists.d.ts","sourceRoot":"","sources":["../../src/utilities/migrationTableExists.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7D,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"migrationTableExists.d.ts","sourceRoot":"","sources":["../../src/utilities/migrationTableExists.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7D,eAAO,MAAM,oBAAoB,YACtB,cAAc,OAClB,cAAc,GAAG,UAAU,KAC/B,OAAO,CAAC,OAAO,CA2BjB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseError.d.ts","sourceRoot":"","sources":["../../src/utilities/parseError.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"parseError.d.ts","sourceRoot":"","sources":["../../src/utilities/parseError.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,UAAU,QAAS,OAAO,OAAO,MAAM,KAAG,MAUtD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pushDevSchema.d.ts","sourceRoot":"","sources":["../../src/utilities/pushDevSchema.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,aAAa,CAAA;AAUvE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"pushDevSchema.d.ts","sourceRoot":"","sources":["../../src/utilities/pushDevSchema.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,aAAa,CAAA;AAUvE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,YAAmB,cAAc,kBA6F1D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rawConstraint.d.ts","sourceRoot":"","sources":["../../src/utilities/rawConstraint.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,eAA2B,CAAA;AAEtD;;GAEG;AACH,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"rawConstraint.d.ts","sourceRoot":"","sources":["../../src/utilities/rawConstraint.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,eAA2B,CAAA;AAEtD;;GAEG;AACH,eAAO,MAAM,aAAa,UAAW,OAAO;;;CAG1C,CAAA;AAEF,eAAO,MAAM,eAAe,UAAW,OAAO,KAAG,KAAK,IAAI,UAAU,CAAC,OAAO,aAAa,CAExF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitizePathSegment.d.ts","sourceRoot":"","sources":["../../src/utilities/sanitizePathSegment.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"sanitizePathSegment.d.ts","sourceRoot":"","sources":["../../src/utilities/sanitizePathSegment.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,mBAAmB,YAAa,MAAM,KAAG,MAQrD,CAAA"}
|
|
@@ -3,11 +3,7 @@ import type { RawTable } from '../types.js';
|
|
|
3
3
|
type Args = {
|
|
4
4
|
block: Block;
|
|
5
5
|
localized: boolean;
|
|
6
|
-
|
|
7
|
-
* @todo make required in v4.0. Usually you'd wanna pass this in
|
|
8
|
-
*/
|
|
9
|
-
parentIsLocalized?: boolean;
|
|
10
|
-
rootTableName: string;
|
|
6
|
+
parentIsLocalized: boolean;
|
|
11
7
|
table: RawTable;
|
|
12
8
|
tableLocales?: RawTable;
|
|
13
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateExistingBlockIsIdentical.d.ts","sourceRoot":"","sources":["../../src/utilities/validateExistingBlockIsIdentical.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAS,cAAc,EAAE,MAAM,SAAS,CAAA;AAS3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,KAAK,CAAA;IACZ,SAAS,EAAE,OAAO,CAAA;IAClB
|
|
1
|
+
{"version":3,"file":"validateExistingBlockIsIdentical.d.ts","sourceRoot":"","sources":["../../src/utilities/validateExistingBlockIsIdentical.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAS,cAAc,EAAE,MAAM,SAAS,CAAA;AAS3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,KAAK,CAAA;IACZ,SAAS,EAAE,OAAO,CAAA;IAClB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,KAAK,EAAE,QAAQ,CAAA;IACf,YAAY,CAAC,EAAE,QAAQ,CAAA;CACxB,CAAA;AA+DD;;GAEG;AACH,eAAO,MAAM,gCAAgC,kEAM1C,IAAI,KAAG,OAwBT,CAAA;AAED,eAAO,MAAM,2BAA2B,eAAwC,CAAA;AAChF,eAAO,MAAM,qBAAqB,UAAW,cAAc,SAAS,MAAM,SAEzE,CAAA;AAED,eAAO,MAAM,qBAAqB,UAAW,cAAc,qBAAqB,MAAM,WAMrF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/validateExistingBlockIsIdentical.ts"],"sourcesContent":["import type { Block, Field, FlattenedBlock } from 'payload'\n\nimport {\n fieldAffectsData,\n fieldHasSubFields,\n fieldShouldBeLocalized,\n tabHasName,\n} from 'payload/shared'\n\nimport type { RawTable } from '../types.js'\n\ntype Args = {\n block: Block\n localized: boolean\n
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/validateExistingBlockIsIdentical.ts"],"sourcesContent":["import type { Block, Field, FlattenedBlock } from 'payload'\n\nimport {\n fieldAffectsData,\n fieldHasSubFields,\n fieldShouldBeLocalized,\n tabHasName,\n} from 'payload/shared'\n\nimport type { RawTable } from '../types.js'\n\ntype Args = {\n block: Block\n localized: boolean\n parentIsLocalized: boolean\n table: RawTable\n tableLocales?: RawTable\n}\n\nconst getFlattenedFieldNames = (args: {\n fields: Field[]\n parentIsLocalized: boolean\n prefix?: string\n}): { localized?: boolean; name: string }[] => {\n const { fields, parentIsLocalized, prefix = '' } = args\n return fields.reduce((fieldsToUse, field) => {\n let fieldPrefix = prefix\n\n if (\n ['array', 'blocks', 'relationship', 'upload'].includes(field.type) ||\n ('hasMany' in field && field.hasMany === true)\n ) {\n return fieldsToUse\n }\n\n if (fieldHasSubFields(field)) {\n fieldPrefix = 'name' in field ? `${prefix}${field.name}_` : prefix\n return [\n ...fieldsToUse,\n ...getFlattenedFieldNames({\n fields: field.fields,\n parentIsLocalized: parentIsLocalized || ('localized' in field && field.localized),\n prefix: fieldPrefix,\n }),\n ]\n }\n\n if (field.type === 'tabs') {\n return [\n ...fieldsToUse,\n ...field.tabs.reduce((tabFields, tab) => {\n fieldPrefix = 'name' in tab ? `${prefix}_${tab.name}` : prefix\n return [\n ...tabFields,\n ...(tabHasName(tab)\n ? [{ ...tab, type: 'tab' }]\n : getFlattenedFieldNames({\n fields: tab.fields,\n parentIsLocalized: parentIsLocalized || tab.localized,\n prefix: fieldPrefix,\n })),\n ]\n }, []),\n ]\n }\n\n if (fieldAffectsData(field)) {\n return [\n ...fieldsToUse,\n {\n name: `${fieldPrefix}${field.name}`,\n localized: fieldShouldBeLocalized({ field, parentIsLocalized }),\n },\n ]\n }\n\n return fieldsToUse\n }, [])\n}\n\n/**\n * returns true if all the fields in a block are identical to the existing table\n */\nexport const validateExistingBlockIsIdentical = ({\n block,\n localized,\n parentIsLocalized,\n table,\n tableLocales,\n}: Args): boolean => {\n const fieldNames = getFlattenedFieldNames({\n fields: block.fields,\n parentIsLocalized: parentIsLocalized || localized,\n })\n\n const missingField =\n // ensure every field from the config is in the matching table\n fieldNames.find(({ name, localized }) => {\n const fieldTable = localized && tableLocales ? tableLocales : table\n return Object.keys(fieldTable.columns).indexOf(name) === -1\n }) ||\n // ensure every table column is matched for every field from the config\n Object.keys(table).find((fieldName) => {\n if (!['_locale', '_order', '_parentID', '_path', '_uuid'].includes(fieldName)) {\n return fieldNames.findIndex((field) => field.name) === -1\n }\n })\n\n if (missingField) {\n return false\n }\n\n return Boolean(localized) === Boolean(table.columns._locale)\n}\n\nexport const InternalBlockTableNameIndex = Symbol('InternalBlockTableNameIndex')\nexport const setInternalBlockIndex = (block: FlattenedBlock, index: number) => {\n block[InternalBlockTableNameIndex] = index\n}\n\nexport const resolveBlockTableName = (block: FlattenedBlock, originalTableName: string) => {\n if (!block[InternalBlockTableNameIndex]) {\n return originalTableName\n }\n\n return `${originalTableName}_${block[InternalBlockTableNameIndex]}`\n}\n"],"names":["fieldAffectsData","fieldHasSubFields","fieldShouldBeLocalized","tabHasName","getFlattenedFieldNames","args","fields","parentIsLocalized","prefix","reduce","fieldsToUse","field","fieldPrefix","includes","type","hasMany","name","localized","tabs","tabFields","tab","validateExistingBlockIsIdentical","block","table","tableLocales","fieldNames","missingField","find","fieldTable","Object","keys","columns","indexOf","fieldName","findIndex","Boolean","_locale","InternalBlockTableNameIndex","Symbol","setInternalBlockIndex","index","resolveBlockTableName","originalTableName"],"mappings":"AAEA,SACEA,gBAAgB,EAChBC,iBAAiB,EACjBC,sBAAsB,EACtBC,UAAU,QACL,iBAAgB;AAYvB,MAAMC,yBAAyB,CAACC;IAK9B,MAAM,EAAEC,MAAM,EAAEC,iBAAiB,EAAEC,SAAS,EAAE,EAAE,GAAGH;IACnD,OAAOC,OAAOG,MAAM,CAAC,CAACC,aAAaC;QACjC,IAAIC,cAAcJ;QAElB,IACE;YAAC;YAAS;YAAU;YAAgB;SAAS,CAACK,QAAQ,CAACF,MAAMG,IAAI,KAChE,aAAaH,SAASA,MAAMI,OAAO,KAAK,MACzC;YACA,OAAOL;QACT;QAEA,IAAIT,kBAAkBU,QAAQ;YAC5BC,cAAc,UAAUD,QAAQ,GAAGH,SAASG,MAAMK,IAAI,CAAC,CAAC,CAAC,GA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EAAuE;IACvEa,OAAOC,IAAI,CAACP,OAAOI,IAAI,CAAC,CAACM;QACvB,IAAI,CAAC;YAAC;YAAW;YAAU;YAAa;YAAS;SAAQ,CAACpB,QAAQ,CAACoB,YAAY;YAC7E,OAAOR,WAAWS,SAAS,CAAC,CAACvB,QAAUA,MAAMK,IAAI,MAAM,CAAC;QAC1D;IACF;IAEF,IAAIU,cAAc;QAChB,OAAO;IACT;IAEA,OAAOS,QAAQlB,eAAekB,QAAQZ,MAAMQ,OAAO,CAACK,OAAO;AAC7D,EAAC;AAED,OAAO,MAAMC,8BAA8BC,OAAO,+BAA8B;AAChF,OAAO,MAAMC,wBAAwB,CAACjB,OAAuBkB;IAC3DlB,KAAK,CAACe,4BAA4B,GAAGG;AACvC,EAAC;AAED,OAAO,MAAMC,wBAAwB,CAACnB,OAAuBoB;IAC3D,IAAI,CAACpB,KAAK,CAACe,4BAA4B,EAAE;QACvC,OAAOK;IACT;IAEA,OAAO,GAAGA,kBAAkB,CAAC,EAAEpB,KAAK,CAACe,4BAA4B,EAAE;AACrE,EAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Postgres max identifier length (NAMEDATALEN - 1). */
|
|
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;
|
|
8
|
+
/**
|
|
9
|
+
* Throws if a table or enum identifier exceeds the Postgres 63-char limit.
|
|
10
|
+
*/
|
|
11
|
+
export declare const validateIdentifierLength: (name: string) => string;
|
|
12
|
+
//# sourceMappingURL=validateIdentifierLength.d.ts.map
|
|
@@ -0,0 +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;;;GAGG;AACH,eAAO,MAAM,4BAA4B,QAA0B,CAAA;AAEnE;;GAEG;AACH,eAAO,MAAM,wBAAwB,SAAU,MAAM,KAAG,MAUvD,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { APIError } from 'payload';
|
|
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;
|
|
7
|
+
/**
|
|
8
|
+
* Throws if a table or enum identifier exceeds the Postgres 63-char limit.
|
|
9
|
+
*/ export const validateIdentifierLength = (name)=>{
|
|
10
|
+
if (name.length > maxIdentifierLength) {
|
|
11
|
+
throw new APIError(`Exceeded max identifier length for table or enum name of ${maxIdentifierLength} characters. Invalid name: ${name}.
|
|
12
|
+
Tip: You can use the dbName property to reduce the table name length.
|
|
13
|
+
`);
|
|
14
|
+
}
|
|
15
|
+
return name;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=validateIdentifierLength.js.map
|
|
@@ -0,0 +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 * 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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { maxIdentifierLength, validateIdentifierLength } from './validateIdentifierLength.js';
|
|
3
|
+
describe('validateIdentifierLength', ()=>{
|
|
4
|
+
it('should return the name unchanged when at or under the 63-char limit', ()=>{
|
|
5
|
+
const name = 'a'.repeat(maxIdentifierLength);
|
|
6
|
+
expect(validateIdentifierLength(name)).toBe(name);
|
|
7
|
+
});
|
|
8
|
+
it('should throw when the name exceeds the 63-char limit', ()=>{
|
|
9
|
+
const name = 'a'.repeat(maxIdentifierLength + 1);
|
|
10
|
+
expect(()=>validateIdentifierLength(name)).toThrow('Exceeded max identifier length');
|
|
11
|
+
});
|
|
12
|
+
it('should include the invalid name and the dbName tip in the error', ()=>{
|
|
13
|
+
const name = `some_long_table_name${'x'.repeat(maxIdentifierLength)}_locales`;
|
|
14
|
+
expect(()=>validateIdentifierLength(name)).toThrow(name);
|
|
15
|
+
expect(()=>validateIdentifierLength(name)).toThrow('You can use the dbName property to reduce the table name length');
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=validateIdentifierLength.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/validateIdentifierLength.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { maxIdentifierLength, validateIdentifierLength } from './validateIdentifierLength.js'\n\ndescribe('validateIdentifierLength', () => {\n it('should return the name unchanged when at or under the 63-char limit', () => {\n const name = 'a'.repeat(maxIdentifierLength)\n\n expect(validateIdentifierLength(name)).toBe(name)\n })\n\n it('should throw when the name exceeds the 63-char limit', () => {\n const name = 'a'.repeat(maxIdentifierLength + 1)\n\n expect(() => validateIdentifierLength(name)).toThrow('Exceeded max identifier length')\n })\n\n it('should include the invalid name and the dbName tip in the error', () => {\n const name = `some_long_table_name${'x'.repeat(maxIdentifierLength)}_locales`\n\n expect(() => validateIdentifierLength(name)).toThrow(name)\n expect(() => validateIdentifierLength(name)).toThrow(\n 'You can use the dbName property to reduce the table name length',\n )\n })\n})\n"],"names":["describe","expect","it","maxIdentifierLength","validateIdentifierLength","name","repeat","toBe","toThrow"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAE7C,SAASC,mBAAmB,EAAEC,wBAAwB,QAAQ,gCAA+B;AAE7FJ,SAAS,4BAA4B;IACnCE,GAAG,uEAAuE;QACxE,MAAMG,OAAO,IAAIC,MAAM,CAACH;QAExBF,OAAOG,yBAAyBC,OAAOE,IAAI,CAACF;IAC9C;IAEAH,GAAG,wDAAwD;QACzD,MAAMG,OAAO,IAAIC,MAAM,CAACH,sBAAsB;QAE9CF,OAAO,IAAMG,yBAAyBC,OAAOG,OAAO,CAAC;IACvD;IAEAN,GAAG,mEAAmE;QACpE,MAAMG,OAAO,CAAC,oBAAoB,EAAE,IAAIC,MAAM,CAACH,qBAAqB,QAAQ,CAAC;QAE7EF,OAAO,IAAMG,yBAAyBC,OAAOG,OAAO,CAACH;QACrDJ,OAAO,IAAMG,yBAAyBC,OAAOG,OAAO,CAClD;IAEJ;AACF"}
|
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": {
|
|
@@ -54,11 +54,11 @@
|
|
|
54
54
|
"@libsql/client": "0.14.0",
|
|
55
55
|
"@types/pg": "8.20.0",
|
|
56
56
|
"@types/to-snake-case": "1.0.0",
|
|
57
|
-
"
|
|
58
|
-
"
|
|
57
|
+
"@payloadcms/eslint-config": "3.28.0",
|
|
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",
|