pqb 0.27.6 → 0.27.7
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/index.d.ts +177 -88
- package/dist/index.js +373 -200
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +371 -202
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -141,9 +141,12 @@ class ColumnType extends orchidCore.ColumnTypeBase {
|
|
|
141
141
|
* // primary key can be used by `find` later:
|
|
142
142
|
* db.table.find('97ba9e78-7510-415a-9c03-23d440aec443');
|
|
143
143
|
* ```
|
|
144
|
+
*
|
|
145
|
+
* @param options - to specify a constraint name
|
|
144
146
|
*/
|
|
145
|
-
primaryKey() {
|
|
146
|
-
|
|
147
|
+
primaryKey(options) {
|
|
148
|
+
var _a;
|
|
149
|
+
return orchidCore.setColumnData(this, "primaryKey", (_a = options == null ? void 0 : options.name) != null ? _a : true);
|
|
147
150
|
}
|
|
148
151
|
foreignKey(fnOrTable, column, options = orchidCore.emptyObject) {
|
|
149
152
|
const item = typeof fnOrTable === "string" ? __spreadValues$h({ table: fnOrTable, columns: [column] }, options) : __spreadValues$h({ fn: fnOrTable, columns: [column] }, options);
|
|
@@ -156,9 +159,9 @@ class ColumnType extends orchidCore.ColumnTypeBase {
|
|
|
156
159
|
return orchidCore.pushColumnData(this, "indexes", options);
|
|
157
160
|
}
|
|
158
161
|
/**
|
|
159
|
-
* `searchIndex` is designed for full text search.
|
|
162
|
+
* `searchIndex` is designed for [full text search](/guide/text-search).
|
|
160
163
|
*
|
|
161
|
-
* It can accept the same options as a regular `index`, but it is `USING GIN` by default, and it is concatenating columns into a `tsvector
|
|
164
|
+
* It can accept the same options as a regular `index`, but it is `USING GIN` by default, and it is concatenating columns into a `tsvector` database type.
|
|
162
165
|
*
|
|
163
166
|
* ```ts
|
|
164
167
|
* import { change } from '../dbScript';
|
|
@@ -166,8 +169,8 @@ class ColumnType extends orchidCore.ColumnTypeBase {
|
|
|
166
169
|
* change(async (db) => {
|
|
167
170
|
* await db.createTable('table', (t) => ({
|
|
168
171
|
* id: t.identity().primaryKey(),
|
|
169
|
-
* title: t.
|
|
170
|
-
* body: t.
|
|
172
|
+
* title: t.text(),
|
|
173
|
+
* body: t.text(),
|
|
171
174
|
* ...t.searchIndex(['title', 'body']),
|
|
172
175
|
* }));
|
|
173
176
|
* });
|
|
@@ -176,10 +179,10 @@ class ColumnType extends orchidCore.ColumnTypeBase {
|
|
|
176
179
|
* Produces the following index ('english' is a default language, see [full text search](/guide/text-search.html#language) for changing it):
|
|
177
180
|
*
|
|
178
181
|
* ```sql
|
|
179
|
-
* CREATE INDEX "table_title_body_idx" ON "table" USING GIN (to_tsvector('english',
|
|
182
|
+
* CREATE INDEX "table_title_body_idx" ON "table" USING GIN (to_tsvector('english', "title" || ' ' || "body"))
|
|
180
183
|
* ```
|
|
181
184
|
*
|
|
182
|
-
*
|
|
185
|
+
* You can set different search weights (`A` to `D`) on different columns inside the index:
|
|
183
186
|
*
|
|
184
187
|
* ```ts
|
|
185
188
|
* import { change } from '../dbScript';
|
|
@@ -187,8 +190,63 @@ class ColumnType extends orchidCore.ColumnTypeBase {
|
|
|
187
190
|
* change(async (db) => {
|
|
188
191
|
* await db.createTable('table', (t) => ({
|
|
189
192
|
* id: t.identity().primaryKey(),
|
|
190
|
-
* title: t.
|
|
191
|
-
* body: t.
|
|
193
|
+
* title: t.text(),
|
|
194
|
+
* body: t.text(),
|
|
195
|
+
* ...t.searchIndex([
|
|
196
|
+
* { column: 'title', weight: 'A' },
|
|
197
|
+
* { column: 'body', weight: 'B' },
|
|
198
|
+
* ]),
|
|
199
|
+
* }));
|
|
200
|
+
* });
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* When the table has localized columns,
|
|
204
|
+
* you can define different indexes for different languages by setting the `language` parameter:
|
|
205
|
+
*
|
|
206
|
+
* ```ts
|
|
207
|
+
* import { change } from '../dbScript';
|
|
208
|
+
*
|
|
209
|
+
* change(async (db) => {
|
|
210
|
+
* await db.createTable('table', (t) => ({
|
|
211
|
+
* id: t.identity().primaryKey(),
|
|
212
|
+
* titleEn: t.text(),
|
|
213
|
+
* bodyEn: t.text(),
|
|
214
|
+
* titleFr: t.text(),
|
|
215
|
+
* bodyFr: t.text(),
|
|
216
|
+
* ...t.searchIndex(['titleEn', 'bodyEn'], { language: 'english' }),
|
|
217
|
+
* ...t.searchIndex(['titleFr', 'bodyFr'], { language: 'french' }),
|
|
218
|
+
* }));
|
|
219
|
+
* });
|
|
220
|
+
* ```
|
|
221
|
+
*
|
|
222
|
+
* Alternatively, different table records may correspond to a single language,
|
|
223
|
+
* then you can define a search index that relies on a language column by using `languageColumn` parameter:
|
|
224
|
+
*
|
|
225
|
+
* ```ts
|
|
226
|
+
* import { change } from '../dbScript';
|
|
227
|
+
*
|
|
228
|
+
* change(async (db) => {
|
|
229
|
+
* await db.createTable('table', (t) => ({
|
|
230
|
+
* id: t.identity().primaryKey(),
|
|
231
|
+
* lang: t.type('regconfig'),
|
|
232
|
+
* title: t.text(),
|
|
233
|
+
* body: t.text(),
|
|
234
|
+
* ...t.searchIndex(['title', 'body'], { languageColumn: 'lang' }),
|
|
235
|
+
* }));
|
|
236
|
+
* });
|
|
237
|
+
* ```
|
|
238
|
+
*
|
|
239
|
+
* It can be more efficient to use a [generated](/guide/migration-column-methods.html#generated-column) column instead of indexing text column in the way described above,
|
|
240
|
+
* and to set a `searchIndex` on it:
|
|
241
|
+
*
|
|
242
|
+
* ```ts
|
|
243
|
+
* import { change } from '../dbScript';
|
|
244
|
+
*
|
|
245
|
+
* change(async (db) => {
|
|
246
|
+
* await db.createTable('table', (t) => ({
|
|
247
|
+
* id: t.identity().primaryKey(),
|
|
248
|
+
* title: t.text(),
|
|
249
|
+
* body: t.text(),
|
|
192
250
|
* generatedTsVector: t.tsvector().generated(['title', 'body']).searchIndex(),
|
|
193
251
|
* }));
|
|
194
252
|
* });
|
|
@@ -269,14 +327,21 @@ const knownDefaults = {
|
|
|
269
327
|
};
|
|
270
328
|
const simplifyColumnDefault = (value) => {
|
|
271
329
|
if (typeof value === "string") {
|
|
272
|
-
|
|
273
|
-
|
|
330
|
+
return new RawSQL([
|
|
331
|
+
[knownDefaults[value.toLowerCase()] || value]
|
|
332
|
+
]);
|
|
274
333
|
}
|
|
275
334
|
return;
|
|
276
335
|
};
|
|
277
336
|
const instantiateColumn = (typeFn, params) => {
|
|
278
337
|
const column = typeFn();
|
|
338
|
+
const { dateTimePrecision } = params;
|
|
279
339
|
Object.assign(column.data, __spreadProps$a(__spreadValues$g({}, params), {
|
|
340
|
+
dateTimePrecision: (
|
|
341
|
+
// 0 is default for date, 6 is default for timestamp
|
|
342
|
+
dateTimePrecision && dateTimePrecision !== 6 ? dateTimePrecision : void 0
|
|
343
|
+
),
|
|
344
|
+
collate: params.collate,
|
|
280
345
|
default: simplifyColumnDefault(params.default)
|
|
281
346
|
}));
|
|
282
347
|
return column;
|
|
@@ -317,7 +382,7 @@ const combineCodeElements = (input) => {
|
|
|
317
382
|
}
|
|
318
383
|
return output;
|
|
319
384
|
};
|
|
320
|
-
const columnsShapeToCode = (shape, tableData, t) => {
|
|
385
|
+
const columnsShapeToCode = (shape, tableData, t, m) => {
|
|
321
386
|
const hasTimestamps = "createdAt" in shape && isDefaultTimeStamp(shape.createdAt) && "updatedAt" in shape && isDefaultTimeStamp(shape.updatedAt);
|
|
322
387
|
const code = [];
|
|
323
388
|
for (const key in shape) {
|
|
@@ -345,19 +410,33 @@ const columnsShapeToCode = (shape, tableData, t) => {
|
|
|
345
410
|
}
|
|
346
411
|
if (constraints) {
|
|
347
412
|
for (const item of constraints) {
|
|
348
|
-
code.push(...constraintToCode(item, t));
|
|
413
|
+
code.push(...constraintToCode(item, t, m));
|
|
349
414
|
}
|
|
350
415
|
}
|
|
351
416
|
return code;
|
|
352
417
|
};
|
|
353
418
|
const primaryKeyToCode = (primaryKey, t) => {
|
|
419
|
+
return `...${primaryKeyInnerToCode(primaryKey, t)},`;
|
|
420
|
+
};
|
|
421
|
+
const primaryKeyInnerToCode = (primaryKey, t) => {
|
|
354
422
|
var _a;
|
|
355
423
|
const name = (_a = primaryKey.options) == null ? void 0 : _a.name;
|
|
356
|
-
return
|
|
424
|
+
return `${t}.primaryKey([${primaryKey.columns.map(orchidCore.singleQuote).join(", ")}]${name ? `, { name: ${orchidCore.singleQuote(name)} }` : ""})`;
|
|
357
425
|
};
|
|
358
426
|
const indexToCode = (index, t) => {
|
|
427
|
+
const code = indexInnerToCode(index, t);
|
|
428
|
+
code[0] = `...${code[0]}`;
|
|
429
|
+
const last = code[code.length - 1];
|
|
430
|
+
if (typeof last === "string" && !last.endsWith(","))
|
|
431
|
+
orchidCore.addCode(code, ",");
|
|
432
|
+
return code;
|
|
433
|
+
};
|
|
434
|
+
const indexInnerToCode = (index, t) => {
|
|
359
435
|
const code = [];
|
|
360
|
-
code.push(
|
|
436
|
+
code.push(
|
|
437
|
+
`${t}.${index.options.tsVector ? "searchIndex" : index.options.unique ? "unique" : "index"}(`
|
|
438
|
+
);
|
|
439
|
+
const columnOptions = ["collate", "opclass", "order", "weight"];
|
|
361
440
|
const columnsMultiline = index.columns.some((column) => {
|
|
362
441
|
for (const key in column) {
|
|
363
442
|
if (key !== "column" && column[key] !== void 0)
|
|
@@ -369,13 +448,13 @@ const indexToCode = (index, t) => {
|
|
|
369
448
|
const objects = [];
|
|
370
449
|
for (const column of index.columns) {
|
|
371
450
|
const expr = "column" in column ? column.column : column.expression;
|
|
372
|
-
let
|
|
451
|
+
let hasOptions = false;
|
|
373
452
|
for (const key in column) {
|
|
374
|
-
if (key !== "column"
|
|
375
|
-
|
|
453
|
+
if (key !== "column") {
|
|
454
|
+
hasOptions = true;
|
|
376
455
|
}
|
|
377
456
|
}
|
|
378
|
-
if (!
|
|
457
|
+
if (!hasOptions) {
|
|
379
458
|
objects.push(`${orchidCore.singleQuote(expr)},`);
|
|
380
459
|
} else {
|
|
381
460
|
const props = [
|
|
@@ -383,14 +462,11 @@ const indexToCode = (index, t) => {
|
|
|
383
462
|
expr
|
|
384
463
|
)},`
|
|
385
464
|
];
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
}
|
|
392
|
-
if (column.order !== void 0) {
|
|
393
|
-
props.push(`order: ${orchidCore.singleQuote(column.order)},`);
|
|
465
|
+
for (const key of columnOptions) {
|
|
466
|
+
const value = column[key];
|
|
467
|
+
if (value !== void 0) {
|
|
468
|
+
props.push(`${key}: ${orchidCore.singleQuote(value)},`);
|
|
469
|
+
}
|
|
394
470
|
}
|
|
395
471
|
objects.push("{", props, "},");
|
|
396
472
|
}
|
|
@@ -402,8 +478,22 @@ const indexToCode = (index, t) => {
|
|
|
402
478
|
`[${index.columns.map((it) => orchidCore.singleQuote(it.column)).join(", ")}]`
|
|
403
479
|
);
|
|
404
480
|
}
|
|
405
|
-
const
|
|
406
|
-
|
|
481
|
+
const indexOptionsKeys = [
|
|
482
|
+
"name",
|
|
483
|
+
"using",
|
|
484
|
+
"nullsNotDistinct",
|
|
485
|
+
"include",
|
|
486
|
+
"with",
|
|
487
|
+
"tablespace",
|
|
488
|
+
"where",
|
|
489
|
+
"language",
|
|
490
|
+
"languageColumn",
|
|
491
|
+
"dropMode"
|
|
492
|
+
];
|
|
493
|
+
if (index.options.tsVector && index.options.unique) {
|
|
494
|
+
indexOptionsKeys.unshift("unique");
|
|
495
|
+
}
|
|
496
|
+
if (indexOptionsKeys.some((key) => index.options[key])) {
|
|
407
497
|
if (columnsMultiline) {
|
|
408
498
|
const columns = code[code.length - 1];
|
|
409
499
|
columns[columns.length - 1] += ",";
|
|
@@ -412,7 +502,7 @@ const indexToCode = (index, t) => {
|
|
|
412
502
|
orchidCore.addCode(code, ", {");
|
|
413
503
|
}
|
|
414
504
|
const options = [];
|
|
415
|
-
for (const key
|
|
505
|
+
for (const key of indexOptionsKeys) {
|
|
416
506
|
const value = index.options[key];
|
|
417
507
|
if (value === null || value === void 0)
|
|
418
508
|
continue;
|
|
@@ -430,25 +520,35 @@ const indexToCode = (index, t) => {
|
|
|
430
520
|
if (columnsMultiline) {
|
|
431
521
|
code.push("),");
|
|
432
522
|
} else {
|
|
433
|
-
orchidCore.addCode(code, ")
|
|
523
|
+
orchidCore.addCode(code, ")");
|
|
434
524
|
}
|
|
435
525
|
return code;
|
|
436
526
|
};
|
|
437
|
-
const constraintToCode = (item, t) => {
|
|
527
|
+
const constraintToCode = (item, t, m) => {
|
|
528
|
+
const code = constraintInnerToCode(item, t, m);
|
|
529
|
+
code[0] = `...${code[0]}`;
|
|
530
|
+
const last = code[code.length - 1];
|
|
531
|
+
if (typeof last === "string" && !last.endsWith(","))
|
|
532
|
+
code[code.length - 1] += ",";
|
|
533
|
+
return code;
|
|
534
|
+
};
|
|
535
|
+
const constraintInnerToCode = (item, t, m) => {
|
|
438
536
|
const kind = getConstraintKind(item);
|
|
439
537
|
if (kind === "foreignKey" && item.references) {
|
|
440
538
|
return [
|
|
441
|
-
|
|
442
|
-
referencesArgsToCode(item.references, item.name),
|
|
539
|
+
`${t}.foreignKey(`,
|
|
540
|
+
referencesArgsToCode(item.references, item.name, m),
|
|
443
541
|
"),"
|
|
444
542
|
];
|
|
445
543
|
} else if (kind === "check" && item.check) {
|
|
446
|
-
return [
|
|
544
|
+
return [
|
|
545
|
+
`${t}.check(${item.check.toCode(t)}${item.name ? `, { name: '${item.name}' }` : ""})`
|
|
546
|
+
];
|
|
447
547
|
} else {
|
|
448
|
-
return [
|
|
548
|
+
return [`${t}.constraint({`, constraintPropsToCode(t, item, m), "}),"];
|
|
449
549
|
}
|
|
450
550
|
};
|
|
451
|
-
const constraintPropsToCode = (t, item) => {
|
|
551
|
+
const constraintPropsToCode = (t, item, m) => {
|
|
452
552
|
const props = [];
|
|
453
553
|
if (item.name) {
|
|
454
554
|
props.push(`name: ${orchidCore.singleQuote(item.name)},`);
|
|
@@ -456,7 +556,7 @@ const constraintPropsToCode = (t, item) => {
|
|
|
456
556
|
if (item.references) {
|
|
457
557
|
props.push(
|
|
458
558
|
`references: [`,
|
|
459
|
-
referencesArgsToCode(item.references, false),
|
|
559
|
+
referencesArgsToCode(item.references, false, m),
|
|
460
560
|
"],"
|
|
461
561
|
);
|
|
462
562
|
}
|
|
@@ -470,9 +570,13 @@ const referencesArgsToCode = ({
|
|
|
470
570
|
fnOrTable,
|
|
471
571
|
foreignColumns,
|
|
472
572
|
options
|
|
473
|
-
}, name = (options == null ? void 0 : options.name) || false) => {
|
|
573
|
+
}, name = (options == null ? void 0 : options.name) || false, m) => {
|
|
474
574
|
const args = [];
|
|
475
575
|
args.push(`${orchidCore.singleQuoteArray(columns)},`);
|
|
576
|
+
if (m && typeof fnOrTable !== "string") {
|
|
577
|
+
const { schema, table } = new (fnOrTable())();
|
|
578
|
+
fnOrTable = schema ? `${schema}.${table}` : table;
|
|
579
|
+
}
|
|
476
580
|
args.push(
|
|
477
581
|
`${typeof fnOrTable === "string" ? orchidCore.singleQuote(fnOrTable) : fnOrTable.toString()},`
|
|
478
582
|
);
|
|
@@ -492,24 +596,27 @@ const referencesArgsToCode = ({
|
|
|
492
596
|
}
|
|
493
597
|
return args;
|
|
494
598
|
};
|
|
495
|
-
const columnForeignKeysToCode = (foreignKeys) => {
|
|
599
|
+
const columnForeignKeysToCode = (foreignKeys, migration) => {
|
|
496
600
|
const code = [];
|
|
497
601
|
for (const foreignKey of foreignKeys) {
|
|
498
602
|
orchidCore.addCode(code, `.foreignKey(`);
|
|
499
|
-
for (const part of foreignKeyArgumentToCode(foreignKey)) {
|
|
603
|
+
for (const part of foreignKeyArgumentToCode(foreignKey, migration)) {
|
|
500
604
|
orchidCore.addCode(code, part);
|
|
501
605
|
}
|
|
502
606
|
orchidCore.addCode(code, ")");
|
|
503
607
|
}
|
|
504
608
|
return code;
|
|
505
609
|
};
|
|
506
|
-
const foreignKeyArgumentToCode = (foreignKey) => {
|
|
610
|
+
const foreignKeyArgumentToCode = (foreignKey, migration) => {
|
|
507
611
|
const code = [];
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
612
|
+
let fnOrTable = "fn" in foreignKey ? foreignKey.fn : foreignKey.table;
|
|
613
|
+
if (migration && typeof fnOrTable !== "string") {
|
|
614
|
+
const { schema, table } = new (fnOrTable())();
|
|
615
|
+
fnOrTable = schema ? `${schema}.${table}` : table;
|
|
512
616
|
}
|
|
617
|
+
code.push(
|
|
618
|
+
typeof fnOrTable === "string" ? orchidCore.singleQuote(fnOrTable) : fnOrTable.toString()
|
|
619
|
+
);
|
|
513
620
|
orchidCore.addCode(code, `, ${orchidCore.singleQuote(foreignKey.columns[0])}`);
|
|
514
621
|
const hasOptions = foreignKey.name || foreignKey.match || foreignKey.onUpdate || foreignKey.onDelete;
|
|
515
622
|
if (hasOptions) {
|
|
@@ -564,8 +671,8 @@ const columnIndexesToCode = (indexes) => {
|
|
|
564
671
|
}
|
|
565
672
|
return code;
|
|
566
673
|
};
|
|
567
|
-
const columnCheckToCode = (t,
|
|
568
|
-
return `.check(${
|
|
674
|
+
const columnCheckToCode = (t, { sql, options }) => {
|
|
675
|
+
return `.check(${sql.toCode(t)}${(options == null ? void 0 : options.name) ? `, { name: '${options.name}' }` : ""})`;
|
|
569
676
|
};
|
|
570
677
|
const identityToCode = (identity, dataType) => {
|
|
571
678
|
const code = [];
|
|
@@ -577,16 +684,18 @@ const identityToCode = (identity, dataType) => {
|
|
|
577
684
|
const props = [];
|
|
578
685
|
if (identity.always)
|
|
579
686
|
props.push(`always: true,`);
|
|
580
|
-
if (identity.
|
|
581
|
-
props.push(`
|
|
582
|
-
if (identity.
|
|
583
|
-
props.push(`
|
|
687
|
+
if (identity.increment && identity.increment !== 1)
|
|
688
|
+
props.push(`increment: ${identity.increment},`);
|
|
689
|
+
if (identity.start && identity.start !== 1)
|
|
690
|
+
props.push(`start: ${identity.start},`);
|
|
584
691
|
if (identity.min)
|
|
585
692
|
props.push(`min: ${identity.min},`);
|
|
586
693
|
if (identity.max)
|
|
587
694
|
props.push(`max: ${identity.max},`);
|
|
588
|
-
if (identity.cache)
|
|
695
|
+
if (identity.cache && identity.cache !== 1)
|
|
589
696
|
props.push(`cache: ${identity.cache},`);
|
|
697
|
+
if (identity.cycle)
|
|
698
|
+
props.push(`cycle: true,`);
|
|
590
699
|
if (props.length) {
|
|
591
700
|
orchidCore.addCode(code, "{");
|
|
592
701
|
code.push(props, "}");
|
|
@@ -594,7 +703,7 @@ const identityToCode = (identity, dataType) => {
|
|
|
594
703
|
orchidCore.addCode(code, ")");
|
|
595
704
|
return code;
|
|
596
705
|
};
|
|
597
|
-
const columnCode = (type, t, code, data = type.data, skip) => {
|
|
706
|
+
const columnCode = (type, t, code, migration, data = type.data, skip) => {
|
|
598
707
|
code = orchidCore.toArray(code);
|
|
599
708
|
let prepend = `${t}.`;
|
|
600
709
|
if (data.name) {
|
|
@@ -605,10 +714,14 @@ const columnCode = (type, t, code, data = type.data, skip) => {
|
|
|
605
714
|
} else {
|
|
606
715
|
code[0].unshift(prepend);
|
|
607
716
|
}
|
|
608
|
-
if (data.
|
|
609
|
-
orchidCore.addCode(
|
|
717
|
+
if (data.primaryKey) {
|
|
718
|
+
orchidCore.addCode(
|
|
719
|
+
code,
|
|
720
|
+
`.primaryKey(${data.primaryKey === true ? "" : `{ name: '${data.primaryKey}' }`})`
|
|
721
|
+
);
|
|
722
|
+
}
|
|
610
723
|
if (data.foreignKeys) {
|
|
611
|
-
for (const part of columnForeignKeysToCode(data.foreignKeys)) {
|
|
724
|
+
for (const part of columnForeignKeysToCode(data.foreignKeys, migration)) {
|
|
612
725
|
orchidCore.addCode(code, part);
|
|
613
726
|
}
|
|
614
727
|
}
|
|
@@ -622,7 +735,7 @@ const columnCode = (type, t, code, data = type.data, skip) => {
|
|
|
622
735
|
orchidCore.addCode(code, `.parse(${type.parseFn.toString()})`);
|
|
623
736
|
if (data.as)
|
|
624
737
|
orchidCore.addCode(code, `.as(${data.as.toCode(t)})`);
|
|
625
|
-
if (data.default !== void 0) {
|
|
738
|
+
if (data.default !== void 0 && (!migration || typeof data.default !== "function")) {
|
|
626
739
|
orchidCore.addCode(code, `.default(${orchidCore.columnDefaultArgumentToCode(t, data.default)})`);
|
|
627
740
|
}
|
|
628
741
|
if (data.indexes) {
|
|
@@ -824,8 +937,8 @@ class JSONColumn extends ColumnType {
|
|
|
824
937
|
this.dataType = "jsonb";
|
|
825
938
|
this.operators = Operators.json;
|
|
826
939
|
}
|
|
827
|
-
toCode(t) {
|
|
828
|
-
return columnCode(this, t, `json()`, this.data, toCodeSkip);
|
|
940
|
+
toCode(t, m) {
|
|
941
|
+
return columnCode(this, t, `json()`, m, this.data, toCodeSkip);
|
|
829
942
|
}
|
|
830
943
|
}
|
|
831
944
|
JSONColumn.prototype.encodeFn = JSON.stringify;
|
|
@@ -835,8 +948,8 @@ class JSONTextColumn extends ColumnType {
|
|
|
835
948
|
this.dataType = "json";
|
|
836
949
|
this.operators = Operators.text;
|
|
837
950
|
}
|
|
838
|
-
toCode(t) {
|
|
839
|
-
return columnCode(this, t, `jsonText()`, this.data, toCodeSkip);
|
|
951
|
+
toCode(t, m) {
|
|
952
|
+
return columnCode(this, t, `jsonText()`, m, this.data, toCodeSkip);
|
|
840
953
|
}
|
|
841
954
|
}
|
|
842
955
|
|
|
@@ -1606,11 +1719,12 @@ class DateColumn extends DateBaseColumn {
|
|
|
1606
1719
|
super(...arguments);
|
|
1607
1720
|
this.dataType = "date";
|
|
1608
1721
|
}
|
|
1609
|
-
toCode(t) {
|
|
1722
|
+
toCode(t, m) {
|
|
1610
1723
|
return columnCode(
|
|
1611
1724
|
this,
|
|
1612
1725
|
t,
|
|
1613
|
-
`date()${orchidCore.dateDataToCode(this.data)}`,
|
|
1726
|
+
`date()${orchidCore.dateDataToCode(this.data, m)}`,
|
|
1727
|
+
m,
|
|
1614
1728
|
this.data,
|
|
1615
1729
|
skipDateMethodsFromToCode
|
|
1616
1730
|
);
|
|
@@ -1637,7 +1751,7 @@ class DateTimeTzBaseClass extends DateTimeBaseClass {
|
|
|
1637
1751
|
);
|
|
1638
1752
|
}
|
|
1639
1753
|
}
|
|
1640
|
-
const timestampToCode = (self, t) => {
|
|
1754
|
+
const timestampToCode = (self, t, m) => {
|
|
1641
1755
|
const { dateTimePrecision: p } = self.data;
|
|
1642
1756
|
const { defaultTimestamp } = self.data;
|
|
1643
1757
|
if (defaultTimestamp) {
|
|
@@ -1649,7 +1763,8 @@ const timestampToCode = (self, t) => {
|
|
|
1649
1763
|
const code = columnCode(
|
|
1650
1764
|
self,
|
|
1651
1765
|
t,
|
|
1652
|
-
`timestamps${noTz}(${p && p !== 6 ? p : ""}).${defaultTimestamp}${orchidCore.dateDataToCode(self.data)}`,
|
|
1766
|
+
`timestamps${noTz}(${p && p !== 6 ? p : ""}).${defaultTimestamp}${orchidCore.dateDataToCode(self.data, m)}`,
|
|
1767
|
+
m,
|
|
1653
1768
|
self.data,
|
|
1654
1769
|
skipDateMethodsFromToCode
|
|
1655
1770
|
);
|
|
@@ -1660,7 +1775,8 @@ const timestampToCode = (self, t) => {
|
|
|
1660
1775
|
return columnCode(
|
|
1661
1776
|
self,
|
|
1662
1777
|
t,
|
|
1663
|
-
`${self instanceof TimestampColumn ? "timestampNoTZ" : "timestamp"}(${p && p !== 6 ? p : ""})${orchidCore.dateDataToCode(self.data)}`,
|
|
1778
|
+
`${self instanceof TimestampColumn ? "timestampNoTZ" : "timestamp"}(${p && p !== 6 ? p : ""})${orchidCore.dateDataToCode(self.data, m)}`,
|
|
1779
|
+
m,
|
|
1664
1780
|
self.data,
|
|
1665
1781
|
skipDateMethodsFromToCode
|
|
1666
1782
|
);
|
|
@@ -1671,8 +1787,8 @@ class TimestampColumn extends DateTimeBaseClass {
|
|
|
1671
1787
|
super(...arguments);
|
|
1672
1788
|
this.dataType = "timestamp";
|
|
1673
1789
|
}
|
|
1674
|
-
toCode(t) {
|
|
1675
|
-
return timestampToCode(this, t);
|
|
1790
|
+
toCode(t, m) {
|
|
1791
|
+
return timestampToCode(this, t, m);
|
|
1676
1792
|
}
|
|
1677
1793
|
}
|
|
1678
1794
|
class TimestampTZColumn extends DateTimeTzBaseClass {
|
|
@@ -1681,8 +1797,8 @@ class TimestampTZColumn extends DateTimeTzBaseClass {
|
|
|
1681
1797
|
this.dataType = "timestamptz";
|
|
1682
1798
|
this.baseDataType = "timestamp";
|
|
1683
1799
|
}
|
|
1684
|
-
toCode(t) {
|
|
1685
|
-
return timestampToCode(this, t);
|
|
1800
|
+
toCode(t, m) {
|
|
1801
|
+
return timestampToCode(this, t, m);
|
|
1686
1802
|
}
|
|
1687
1803
|
}
|
|
1688
1804
|
class TimeColumn extends ColumnType {
|
|
@@ -1692,12 +1808,13 @@ class TimeColumn extends ColumnType {
|
|
|
1692
1808
|
this.operators = Operators.time;
|
|
1693
1809
|
this.data.dateTimePrecision = dateTimePrecision;
|
|
1694
1810
|
}
|
|
1695
|
-
toCode(t) {
|
|
1811
|
+
toCode(t, m) {
|
|
1696
1812
|
const { dateTimePrecision } = this.data;
|
|
1697
1813
|
return columnCode(
|
|
1698
1814
|
this,
|
|
1699
1815
|
t,
|
|
1700
|
-
`time(${dateTimePrecision || ""})${orchidCore.dateDataToCode(this.data)}`,
|
|
1816
|
+
`time(${dateTimePrecision || ""})${orchidCore.dateDataToCode(this.data, m)}`,
|
|
1817
|
+
m,
|
|
1701
1818
|
this.data,
|
|
1702
1819
|
skipDateMethodsFromToCode
|
|
1703
1820
|
);
|
|
@@ -1711,12 +1828,13 @@ class IntervalColumn extends ColumnType {
|
|
|
1711
1828
|
this.data.fields = fields;
|
|
1712
1829
|
this.data.precision = precision;
|
|
1713
1830
|
}
|
|
1714
|
-
toCode(t) {
|
|
1831
|
+
toCode(t, m) {
|
|
1715
1832
|
const { fields, precision } = this.data;
|
|
1716
1833
|
return columnCode(
|
|
1717
1834
|
this,
|
|
1718
1835
|
t,
|
|
1719
1836
|
`interval(${[fields && `'${fields}'`, precision && String(precision)].filter((part) => part).join(", ")})`,
|
|
1837
|
+
m,
|
|
1720
1838
|
this.data,
|
|
1721
1839
|
skipDateMethodsFromToCode
|
|
1722
1840
|
);
|
|
@@ -1739,9 +1857,9 @@ class EnumColumn extends ColumnType {
|
|
|
1739
1857
|
this.dataType = "enum";
|
|
1740
1858
|
this.inputSchema = this.outputSchema = this.querySchema = schemaType;
|
|
1741
1859
|
}
|
|
1742
|
-
toCode(t,
|
|
1743
|
-
const options =
|
|
1744
|
-
return columnCode(this, t, `enum('${this.enumName}'${options})
|
|
1860
|
+
toCode(t, m) {
|
|
1861
|
+
const options = m ? "" : `, [${this.options.map((option) => `'${option}'`).join(", ")}]`;
|
|
1862
|
+
return columnCode(this, t, `enum('${this.enumName}'${options})`, m);
|
|
1745
1863
|
}
|
|
1746
1864
|
toSQL() {
|
|
1747
1865
|
const name = this.enumName;
|
|
@@ -1773,15 +1891,16 @@ class ArrayColumn extends ColumnType {
|
|
|
1773
1891
|
}
|
|
1774
1892
|
);
|
|
1775
1893
|
this.data.item = item;
|
|
1894
|
+
this.data.name = item.data.name;
|
|
1776
1895
|
}
|
|
1777
1896
|
toSQL() {
|
|
1778
1897
|
return `${this.data.item.toSQL()}[]`;
|
|
1779
1898
|
}
|
|
1780
|
-
toCode(t) {
|
|
1899
|
+
toCode(t, m) {
|
|
1781
1900
|
const code = ["array("];
|
|
1782
1901
|
orchidCore.addCode(code, this.data.item.toCode(t));
|
|
1783
|
-
orchidCore.addCode(code, `)${orchidCore.arrayDataToCode(this.data)}`);
|
|
1784
|
-
return columnCode(this, t, code);
|
|
1902
|
+
orchidCore.addCode(code, `)${orchidCore.arrayDataToCode(this.data, m)}`);
|
|
1903
|
+
return columnCode(this, t, code, m);
|
|
1785
1904
|
}
|
|
1786
1905
|
}
|
|
1787
1906
|
const parseArray = (input, pos, len, entries, nested, item) => {
|
|
@@ -4064,16 +4183,18 @@ class DecimalColumn extends ColumnType {
|
|
|
4064
4183
|
constructor(schema, numericPrecision, numericScale) {
|
|
4065
4184
|
super(schema, schema.stringSchema());
|
|
4066
4185
|
this.operators = Operators.number;
|
|
4067
|
-
this.dataType = "
|
|
4186
|
+
this.dataType = "numeric";
|
|
4068
4187
|
this.data.numericPrecision = numericPrecision;
|
|
4069
4188
|
this.data.numericScale = numericScale;
|
|
4189
|
+
this.data.alias = "decimal";
|
|
4070
4190
|
}
|
|
4071
|
-
toCode(t) {
|
|
4191
|
+
toCode(t, m) {
|
|
4072
4192
|
const { numericPrecision, numericScale } = this.data;
|
|
4073
4193
|
return columnCode(
|
|
4074
4194
|
this,
|
|
4075
4195
|
t,
|
|
4076
|
-
`decimal(${numericPrecision || ""}${numericScale ? `, ${numericScale}` : ""})
|
|
4196
|
+
`decimal(${numericPrecision || ""}${numericScale ? `, ${numericScale}` : ""})`,
|
|
4197
|
+
m
|
|
4077
4198
|
);
|
|
4078
4199
|
}
|
|
4079
4200
|
toSQL() {
|
|
@@ -4085,49 +4206,52 @@ class DecimalColumn extends ColumnType {
|
|
|
4085
4206
|
}
|
|
4086
4207
|
}
|
|
4087
4208
|
const skipNumberMethods = { int: true };
|
|
4088
|
-
const intToCode = (column, t) => {
|
|
4209
|
+
const intToCode = (column, t, alias, m) => {
|
|
4089
4210
|
let code;
|
|
4090
4211
|
if (column.data.identity) {
|
|
4091
|
-
code = identityToCode(column.data.identity,
|
|
4212
|
+
code = identityToCode(column.data.identity, alias);
|
|
4092
4213
|
} else {
|
|
4093
|
-
code = [`${
|
|
4214
|
+
code = [`${alias}()`];
|
|
4094
4215
|
}
|
|
4095
|
-
orchidCore.addCode(code, orchidCore.numberDataToCode(column.data, skipNumberMethods));
|
|
4096
|
-
return columnCode(column, t, code);
|
|
4216
|
+
orchidCore.addCode(code, orchidCore.numberDataToCode(column.data, m, skipNumberMethods));
|
|
4217
|
+
return columnCode(column, t, code, m);
|
|
4097
4218
|
};
|
|
4098
4219
|
class SmallIntColumn extends IntegerBaseColumn {
|
|
4099
|
-
constructor() {
|
|
4100
|
-
super(
|
|
4101
|
-
this.dataType = "
|
|
4220
|
+
constructor(schema) {
|
|
4221
|
+
super(schema);
|
|
4222
|
+
this.dataType = "int2";
|
|
4102
4223
|
this.parseItem = parseInt;
|
|
4224
|
+
this.data.alias = "smallint";
|
|
4103
4225
|
}
|
|
4104
|
-
toCode(t) {
|
|
4105
|
-
return intToCode(this, t);
|
|
4226
|
+
toCode(t, m) {
|
|
4227
|
+
return intToCode(this, t, "smallint", m);
|
|
4106
4228
|
}
|
|
4107
4229
|
identity(options = {}) {
|
|
4108
4230
|
return orchidCore.setColumnData(this, "identity", options);
|
|
4109
4231
|
}
|
|
4110
4232
|
}
|
|
4111
4233
|
class IntegerColumn extends IntegerBaseColumn {
|
|
4112
|
-
constructor() {
|
|
4113
|
-
super(
|
|
4114
|
-
this.dataType = "
|
|
4234
|
+
constructor(schema) {
|
|
4235
|
+
super(schema);
|
|
4236
|
+
this.dataType = "int4";
|
|
4115
4237
|
this.parseItem = parseInt;
|
|
4238
|
+
this.data.alias = "integer";
|
|
4116
4239
|
}
|
|
4117
|
-
toCode(t) {
|
|
4118
|
-
return intToCode(this, t);
|
|
4240
|
+
toCode(t, m) {
|
|
4241
|
+
return intToCode(this, t, "integer", m);
|
|
4119
4242
|
}
|
|
4120
4243
|
identity(options = {}) {
|
|
4121
4244
|
return orchidCore.setColumnData(this, "identity", options);
|
|
4122
4245
|
}
|
|
4123
4246
|
}
|
|
4124
4247
|
class BigIntColumn extends NumberAsStringBaseColumn {
|
|
4125
|
-
constructor() {
|
|
4126
|
-
super(
|
|
4127
|
-
this.dataType = "
|
|
4248
|
+
constructor(schema) {
|
|
4249
|
+
super(schema);
|
|
4250
|
+
this.dataType = "int8";
|
|
4251
|
+
this.data.alias = "bigint";
|
|
4128
4252
|
}
|
|
4129
|
-
toCode(t) {
|
|
4130
|
-
return intToCode(this, t);
|
|
4253
|
+
toCode(t, m) {
|
|
4254
|
+
return intToCode(this, t, "bigint", m);
|
|
4131
4255
|
}
|
|
4132
4256
|
identity(options = {}) {
|
|
4133
4257
|
return orchidCore.setColumnData(this, "identity", options);
|
|
@@ -4136,68 +4260,75 @@ class BigIntColumn extends NumberAsStringBaseColumn {
|
|
|
4136
4260
|
class RealColumn extends NumberBaseColumn {
|
|
4137
4261
|
constructor(schema) {
|
|
4138
4262
|
super(schema, schema.number());
|
|
4139
|
-
this.dataType = "
|
|
4263
|
+
this.dataType = "float4";
|
|
4140
4264
|
this.parseItem = parseFloat;
|
|
4265
|
+
this.data.alias = "real";
|
|
4141
4266
|
}
|
|
4142
|
-
toCode(t) {
|
|
4143
|
-
return columnCode(this, t, `real()${orchidCore.numberDataToCode(this.data)}
|
|
4267
|
+
toCode(t, m) {
|
|
4268
|
+
return columnCode(this, t, `real()${orchidCore.numberDataToCode(this.data, m)}`, m);
|
|
4144
4269
|
}
|
|
4145
4270
|
}
|
|
4146
4271
|
class DoublePrecisionColumn extends NumberAsStringBaseColumn {
|
|
4147
|
-
constructor() {
|
|
4148
|
-
super(
|
|
4149
|
-
this.dataType = "
|
|
4272
|
+
constructor(schema) {
|
|
4273
|
+
super(schema);
|
|
4274
|
+
this.dataType = "float8";
|
|
4275
|
+
this.data.alias = "doublePrecision";
|
|
4150
4276
|
}
|
|
4151
|
-
toCode(t) {
|
|
4152
|
-
return columnCode(this, t, `doublePrecision()
|
|
4277
|
+
toCode(t, m) {
|
|
4278
|
+
return columnCode(this, t, `doublePrecision()`, m);
|
|
4153
4279
|
}
|
|
4154
4280
|
}
|
|
4155
4281
|
class SmallSerialColumn extends IntegerBaseColumn {
|
|
4156
4282
|
constructor(schema) {
|
|
4157
4283
|
super(schema);
|
|
4158
|
-
this.dataType = "
|
|
4284
|
+
this.dataType = "int2";
|
|
4159
4285
|
this.parseItem = parseInt;
|
|
4160
4286
|
this.data.int = true;
|
|
4287
|
+
this.data.alias = "smallSerial";
|
|
4161
4288
|
}
|
|
4162
4289
|
toSQL() {
|
|
4163
4290
|
return "smallserial";
|
|
4164
4291
|
}
|
|
4165
|
-
toCode(t) {
|
|
4292
|
+
toCode(t, m) {
|
|
4166
4293
|
return columnCode(
|
|
4167
4294
|
this,
|
|
4168
4295
|
t,
|
|
4169
|
-
`smallSerial()${orchidCore.numberDataToCode(this.data, skipNumberMethods)}
|
|
4296
|
+
`smallSerial()${orchidCore.numberDataToCode(this.data, m, skipNumberMethods)}`,
|
|
4297
|
+
m
|
|
4170
4298
|
);
|
|
4171
4299
|
}
|
|
4172
4300
|
}
|
|
4173
4301
|
class SerialColumn extends IntegerBaseColumn {
|
|
4174
4302
|
constructor(schema) {
|
|
4175
4303
|
super(schema);
|
|
4176
|
-
this.dataType = "
|
|
4304
|
+
this.dataType = "int4";
|
|
4177
4305
|
this.parseItem = parseInt;
|
|
4178
4306
|
this.data.int = true;
|
|
4307
|
+
this.data.alias = "serial";
|
|
4179
4308
|
}
|
|
4180
4309
|
toSQL() {
|
|
4181
4310
|
return "serial";
|
|
4182
4311
|
}
|
|
4183
|
-
toCode(t) {
|
|
4312
|
+
toCode(t, m) {
|
|
4184
4313
|
return columnCode(
|
|
4185
4314
|
this,
|
|
4186
4315
|
t,
|
|
4187
|
-
`serial()${orchidCore.numberDataToCode(this.data, skipNumberMethods)}
|
|
4316
|
+
`serial()${orchidCore.numberDataToCode(this.data, m, skipNumberMethods)}`,
|
|
4317
|
+
m
|
|
4188
4318
|
);
|
|
4189
4319
|
}
|
|
4190
4320
|
}
|
|
4191
4321
|
class BigSerialColumn extends NumberAsStringBaseColumn {
|
|
4192
|
-
constructor() {
|
|
4193
|
-
super(
|
|
4194
|
-
this.dataType = "
|
|
4322
|
+
constructor(schema) {
|
|
4323
|
+
super(schema);
|
|
4324
|
+
this.dataType = "int8";
|
|
4325
|
+
this.data.alias = "bigint";
|
|
4195
4326
|
}
|
|
4196
4327
|
toSQL() {
|
|
4197
4328
|
return "bigserial";
|
|
4198
4329
|
}
|
|
4199
|
-
toCode(t) {
|
|
4200
|
-
return columnCode(this, t, `bigSerial()
|
|
4330
|
+
toCode(t, m) {
|
|
4331
|
+
return columnCode(this, t, `bigSerial()`, m);
|
|
4201
4332
|
}
|
|
4202
4333
|
}
|
|
4203
4334
|
|
|
@@ -4246,12 +4377,13 @@ class VarCharColumn extends LimitedTextBaseColumn {
|
|
|
4246
4377
|
super(...arguments);
|
|
4247
4378
|
this.dataType = "varchar";
|
|
4248
4379
|
}
|
|
4249
|
-
toCode(t) {
|
|
4380
|
+
toCode(t, m) {
|
|
4250
4381
|
const { maxChars } = this.data;
|
|
4251
4382
|
return columnCode(
|
|
4252
4383
|
this,
|
|
4253
4384
|
t,
|
|
4254
|
-
`varchar(${maxChars != null ? maxChars : ""})${orchidCore.stringDataToCode(this.data)}
|
|
4385
|
+
`varchar(${maxChars != null ? maxChars : ""})${orchidCore.stringDataToCode(this.data, m)}`,
|
|
4386
|
+
m
|
|
4255
4387
|
);
|
|
4256
4388
|
}
|
|
4257
4389
|
}
|
|
@@ -4259,14 +4391,15 @@ class StringColumn extends VarCharColumn {
|
|
|
4259
4391
|
constructor(schema, limit = 255) {
|
|
4260
4392
|
super(schema, limit);
|
|
4261
4393
|
}
|
|
4262
|
-
toCode(t) {
|
|
4394
|
+
toCode(t, m) {
|
|
4263
4395
|
let max = this.data.maxChars;
|
|
4264
4396
|
if (max === 255)
|
|
4265
4397
|
max = void 0;
|
|
4266
4398
|
return columnCode(
|
|
4267
4399
|
this,
|
|
4268
4400
|
t,
|
|
4269
|
-
`string(${max != null ? max : ""})${orchidCore.stringDataToCode(this.data)}
|
|
4401
|
+
`string(${max != null ? max : ""})${orchidCore.stringDataToCode(this.data, m)}`,
|
|
4402
|
+
m
|
|
4270
4403
|
);
|
|
4271
4404
|
}
|
|
4272
4405
|
}
|
|
@@ -4275,12 +4408,13 @@ class CharColumn extends LimitedTextBaseColumn {
|
|
|
4275
4408
|
super(...arguments);
|
|
4276
4409
|
this.dataType = "char";
|
|
4277
4410
|
}
|
|
4278
|
-
toCode(t) {
|
|
4411
|
+
toCode(t, m) {
|
|
4279
4412
|
const { maxChars } = this.data;
|
|
4280
4413
|
return columnCode(
|
|
4281
4414
|
this,
|
|
4282
4415
|
t,
|
|
4283
|
-
`char(${maxChars != null ? maxChars : ""})${orchidCore.stringDataToCode(this.data)}
|
|
4416
|
+
`char(${maxChars != null ? maxChars : ""})${orchidCore.stringDataToCode(this.data, m)}`,
|
|
4417
|
+
m
|
|
4284
4418
|
);
|
|
4285
4419
|
}
|
|
4286
4420
|
}
|
|
@@ -4292,7 +4426,7 @@ const setTextColumnData = (column, minArg, maxArg) => {
|
|
|
4292
4426
|
}
|
|
4293
4427
|
}
|
|
4294
4428
|
};
|
|
4295
|
-
const textColumnToCode = (column, t) => {
|
|
4429
|
+
const textColumnToCode = (column, t, m) => {
|
|
4296
4430
|
const data = __spreadValues$9({}, column.data);
|
|
4297
4431
|
let args = "";
|
|
4298
4432
|
const hasMax = data.maxArg !== void 0 && data.max === data.maxArg;
|
|
@@ -4311,7 +4445,8 @@ const textColumnToCode = (column, t) => {
|
|
|
4311
4445
|
return columnCode(
|
|
4312
4446
|
column,
|
|
4313
4447
|
t,
|
|
4314
|
-
`${column.dataType}(${args})${orchidCore.stringDataToCode(data)}
|
|
4448
|
+
`${column.dataType}(${args})${orchidCore.stringDataToCode(data, m)}`,
|
|
4449
|
+
m
|
|
4315
4450
|
);
|
|
4316
4451
|
};
|
|
4317
4452
|
const minMaxToSchema = (schema, min, max) => min ? max ? schema.stringMinMax(min, max) : schema.stringMin(min) : schema.stringSchema();
|
|
@@ -4321,8 +4456,8 @@ class TextColumn extends TextBaseColumn {
|
|
|
4321
4456
|
this.dataType = "text";
|
|
4322
4457
|
setTextColumnData(this, min, max);
|
|
4323
4458
|
}
|
|
4324
|
-
toCode(t) {
|
|
4325
|
-
return textColumnToCode(this, t);
|
|
4459
|
+
toCode(t, m) {
|
|
4460
|
+
return textColumnToCode(this, t, m);
|
|
4326
4461
|
}
|
|
4327
4462
|
}
|
|
4328
4463
|
class ByteaColumn extends ColumnType {
|
|
@@ -4331,8 +4466,8 @@ class ByteaColumn extends ColumnType {
|
|
|
4331
4466
|
this.dataType = "bytea";
|
|
4332
4467
|
this.operators = Operators.text;
|
|
4333
4468
|
}
|
|
4334
|
-
toCode(t) {
|
|
4335
|
-
return columnCode(this, t, `bytea()
|
|
4469
|
+
toCode(t, m) {
|
|
4470
|
+
return columnCode(this, t, `bytea()`, m);
|
|
4336
4471
|
}
|
|
4337
4472
|
}
|
|
4338
4473
|
class PointColumn extends ColumnType {
|
|
@@ -4341,8 +4476,8 @@ class PointColumn extends ColumnType {
|
|
|
4341
4476
|
this.dataType = "point";
|
|
4342
4477
|
this.operators = Operators.text;
|
|
4343
4478
|
}
|
|
4344
|
-
toCode(t) {
|
|
4345
|
-
return columnCode(this, t, `point()
|
|
4479
|
+
toCode(t, m) {
|
|
4480
|
+
return columnCode(this, t, `point()`, m);
|
|
4346
4481
|
}
|
|
4347
4482
|
}
|
|
4348
4483
|
class LineColumn extends ColumnType {
|
|
@@ -4351,8 +4486,8 @@ class LineColumn extends ColumnType {
|
|
|
4351
4486
|
this.dataType = "line";
|
|
4352
4487
|
this.operators = Operators.text;
|
|
4353
4488
|
}
|
|
4354
|
-
toCode(t) {
|
|
4355
|
-
return columnCode(this, t, `line()
|
|
4489
|
+
toCode(t, m) {
|
|
4490
|
+
return columnCode(this, t, `line()`, m);
|
|
4356
4491
|
}
|
|
4357
4492
|
}
|
|
4358
4493
|
class LsegColumn extends ColumnType {
|
|
@@ -4361,8 +4496,8 @@ class LsegColumn extends ColumnType {
|
|
|
4361
4496
|
this.dataType = "lseg";
|
|
4362
4497
|
this.operators = Operators.text;
|
|
4363
4498
|
}
|
|
4364
|
-
toCode(t) {
|
|
4365
|
-
return columnCode(this, t, `lseg()
|
|
4499
|
+
toCode(t, m) {
|
|
4500
|
+
return columnCode(this, t, `lseg()`, m);
|
|
4366
4501
|
}
|
|
4367
4502
|
}
|
|
4368
4503
|
class BoxColumn extends ColumnType {
|
|
@@ -4371,8 +4506,8 @@ class BoxColumn extends ColumnType {
|
|
|
4371
4506
|
this.dataType = "box";
|
|
4372
4507
|
this.operators = Operators.text;
|
|
4373
4508
|
}
|
|
4374
|
-
toCode(t) {
|
|
4375
|
-
return columnCode(this, t, `box()
|
|
4509
|
+
toCode(t, m) {
|
|
4510
|
+
return columnCode(this, t, `box()`, m);
|
|
4376
4511
|
}
|
|
4377
4512
|
}
|
|
4378
4513
|
class PathColumn extends ColumnType {
|
|
@@ -4381,8 +4516,8 @@ class PathColumn extends ColumnType {
|
|
|
4381
4516
|
this.dataType = "path";
|
|
4382
4517
|
this.operators = Operators.text;
|
|
4383
4518
|
}
|
|
4384
|
-
toCode(t) {
|
|
4385
|
-
return columnCode(this, t, `path()
|
|
4519
|
+
toCode(t, m) {
|
|
4520
|
+
return columnCode(this, t, `path()`, m);
|
|
4386
4521
|
}
|
|
4387
4522
|
}
|
|
4388
4523
|
class PolygonColumn extends ColumnType {
|
|
@@ -4391,8 +4526,8 @@ class PolygonColumn extends ColumnType {
|
|
|
4391
4526
|
this.dataType = "polygon";
|
|
4392
4527
|
this.operators = Operators.text;
|
|
4393
4528
|
}
|
|
4394
|
-
toCode(t) {
|
|
4395
|
-
return columnCode(this, t, `polygon()
|
|
4529
|
+
toCode(t, m) {
|
|
4530
|
+
return columnCode(this, t, `polygon()`, m);
|
|
4396
4531
|
}
|
|
4397
4532
|
}
|
|
4398
4533
|
class CircleColumn extends ColumnType {
|
|
@@ -4401,8 +4536,8 @@ class CircleColumn extends ColumnType {
|
|
|
4401
4536
|
this.dataType = "circle";
|
|
4402
4537
|
this.operators = Operators.text;
|
|
4403
4538
|
}
|
|
4404
|
-
toCode(t) {
|
|
4405
|
-
return columnCode(this, t, `circle()
|
|
4539
|
+
toCode(t, m) {
|
|
4540
|
+
return columnCode(this, t, `circle()`, m);
|
|
4406
4541
|
}
|
|
4407
4542
|
}
|
|
4408
4543
|
class MoneyColumn extends NumberBaseColumn {
|
|
@@ -4418,8 +4553,8 @@ class MoneyColumn extends NumberBaseColumn {
|
|
|
4418
4553
|
}
|
|
4419
4554
|
);
|
|
4420
4555
|
}
|
|
4421
|
-
toCode(t) {
|
|
4422
|
-
return columnCode(this, t, `money()
|
|
4556
|
+
toCode(t, m) {
|
|
4557
|
+
return columnCode(this, t, `money()`, m);
|
|
4423
4558
|
}
|
|
4424
4559
|
}
|
|
4425
4560
|
class CidrColumn extends ColumnType {
|
|
@@ -4428,8 +4563,8 @@ class CidrColumn extends ColumnType {
|
|
|
4428
4563
|
this.dataType = "cidr";
|
|
4429
4564
|
this.operators = Operators.text;
|
|
4430
4565
|
}
|
|
4431
|
-
toCode(t) {
|
|
4432
|
-
return columnCode(this, t, `cidr()
|
|
4566
|
+
toCode(t, m) {
|
|
4567
|
+
return columnCode(this, t, `cidr()`, m);
|
|
4433
4568
|
}
|
|
4434
4569
|
}
|
|
4435
4570
|
class InetColumn extends ColumnType {
|
|
@@ -4438,8 +4573,8 @@ class InetColumn extends ColumnType {
|
|
|
4438
4573
|
this.dataType = "inet";
|
|
4439
4574
|
this.operators = Operators.text;
|
|
4440
4575
|
}
|
|
4441
|
-
toCode(t) {
|
|
4442
|
-
return columnCode(this, t, `inet()
|
|
4576
|
+
toCode(t, m) {
|
|
4577
|
+
return columnCode(this, t, `inet()`, m);
|
|
4443
4578
|
}
|
|
4444
4579
|
}
|
|
4445
4580
|
class MacAddrColumn extends ColumnType {
|
|
@@ -4448,8 +4583,8 @@ class MacAddrColumn extends ColumnType {
|
|
|
4448
4583
|
this.dataType = "macaddr";
|
|
4449
4584
|
this.operators = Operators.text;
|
|
4450
4585
|
}
|
|
4451
|
-
toCode(t) {
|
|
4452
|
-
return columnCode(this, t, `macaddr()
|
|
4586
|
+
toCode(t, m) {
|
|
4587
|
+
return columnCode(this, t, `macaddr()`, m);
|
|
4453
4588
|
}
|
|
4454
4589
|
}
|
|
4455
4590
|
class MacAddr8Column extends ColumnType {
|
|
@@ -4458,8 +4593,8 @@ class MacAddr8Column extends ColumnType {
|
|
|
4458
4593
|
this.dataType = "macaddr8";
|
|
4459
4594
|
this.operators = Operators.text;
|
|
4460
4595
|
}
|
|
4461
|
-
toCode(t) {
|
|
4462
|
-
return columnCode(this, t, `macaddr8()
|
|
4596
|
+
toCode(t, m) {
|
|
4597
|
+
return columnCode(this, t, `macaddr8()`, m);
|
|
4463
4598
|
}
|
|
4464
4599
|
}
|
|
4465
4600
|
class BitColumn extends ColumnType {
|
|
@@ -4469,9 +4604,9 @@ class BitColumn extends ColumnType {
|
|
|
4469
4604
|
this.operators = Operators.text;
|
|
4470
4605
|
this.data.length = length;
|
|
4471
4606
|
}
|
|
4472
|
-
toCode(t) {
|
|
4607
|
+
toCode(t, m) {
|
|
4473
4608
|
const { length } = this.data;
|
|
4474
|
-
return columnCode(this, t, `bit(${length})
|
|
4609
|
+
return columnCode(this, t, `bit(${length})`, m);
|
|
4475
4610
|
}
|
|
4476
4611
|
toSQL() {
|
|
4477
4612
|
return orchidCore.joinTruthy(
|
|
@@ -4483,13 +4618,14 @@ class BitColumn extends ColumnType {
|
|
|
4483
4618
|
class BitVaryingColumn extends ColumnType {
|
|
4484
4619
|
constructor(schema, length) {
|
|
4485
4620
|
super(schema, schema.bit(length));
|
|
4486
|
-
this.dataType = "
|
|
4621
|
+
this.dataType = "varbit";
|
|
4487
4622
|
this.operators = Operators.text;
|
|
4488
4623
|
this.data.length = length;
|
|
4624
|
+
this.data.alias = "bitVarying";
|
|
4489
4625
|
}
|
|
4490
|
-
toCode(t) {
|
|
4626
|
+
toCode(t, m) {
|
|
4491
4627
|
const { length } = this.data;
|
|
4492
|
-
return columnCode(this, t, `bitVarying(${length != null ? length : ""})
|
|
4628
|
+
return columnCode(this, t, `bitVarying(${length != null ? length : ""})`, m);
|
|
4493
4629
|
}
|
|
4494
4630
|
toSQL() {
|
|
4495
4631
|
return orchidCore.joinTruthy(
|
|
@@ -4505,8 +4641,8 @@ class TsVectorColumn extends ColumnType {
|
|
|
4505
4641
|
this.dataType = "tsvector";
|
|
4506
4642
|
this.operators = Operators.text;
|
|
4507
4643
|
}
|
|
4508
|
-
toCode(t) {
|
|
4509
|
-
return columnCode(this, t, `tsvector()
|
|
4644
|
+
toCode(t, m) {
|
|
4645
|
+
return columnCode(this, t, `tsvector()`, m);
|
|
4510
4646
|
}
|
|
4511
4647
|
/**
|
|
4512
4648
|
* For `tsvector` column type, it can also accept language (optional) and columns:
|
|
@@ -4536,14 +4672,17 @@ class TsVectorColumn extends ColumnType {
|
|
|
4536
4672
|
const first = args[0];
|
|
4537
4673
|
if (typeof first === "string" || !("raw" in first)) {
|
|
4538
4674
|
const target = typeof first === "string" ? args[1] : first;
|
|
4675
|
+
const language = typeof first === "string" ? first : this.defaultLanguage;
|
|
4539
4676
|
let sql;
|
|
4540
4677
|
if (Array.isArray(target)) {
|
|
4541
4678
|
const columns = target.length === 1 ? `"${target[0]}"` : target.map((column) => `coalesce("${column}", '')`).join(` || ' ' || `);
|
|
4542
|
-
sql = `to_tsvector('${
|
|
4679
|
+
sql = `to_tsvector('${language}', ${columns})`;
|
|
4543
4680
|
} else {
|
|
4544
4681
|
for (const key in target) {
|
|
4545
|
-
sql = (sql ? sql + " || " : "") + `setweight(to_tsvector(coalesce("${key}", '')), '${target[key]}')`;
|
|
4682
|
+
sql = (sql ? sql + " || " : "(") + `setweight(to_tsvector('${language}', coalesce("${key}", '')), '${target[key]}')`;
|
|
4546
4683
|
}
|
|
4684
|
+
if (sql)
|
|
4685
|
+
sql += ")";
|
|
4547
4686
|
}
|
|
4548
4687
|
const arr = [sql];
|
|
4549
4688
|
arr.raw = arr;
|
|
@@ -4558,8 +4697,8 @@ class TsQueryColumn extends ColumnType {
|
|
|
4558
4697
|
this.dataType = "tsquery";
|
|
4559
4698
|
this.operators = Operators.text;
|
|
4560
4699
|
}
|
|
4561
|
-
toCode(t) {
|
|
4562
|
-
return columnCode(this, t, `tsquery()
|
|
4700
|
+
toCode(t, m) {
|
|
4701
|
+
return columnCode(this, t, `tsquery()`, m);
|
|
4563
4702
|
}
|
|
4564
4703
|
}
|
|
4565
4704
|
const uuidDefaultSQL = "gen_random_uuid()";
|
|
@@ -4576,12 +4715,13 @@ class UUIDColumn extends ColumnType {
|
|
|
4576
4715
|
column.data.default = uuidDefault;
|
|
4577
4716
|
return column;
|
|
4578
4717
|
}
|
|
4579
|
-
toCode(t) {
|
|
4718
|
+
toCode(t, m) {
|
|
4580
4719
|
const { data } = this;
|
|
4581
4720
|
return columnCode(
|
|
4582
4721
|
this,
|
|
4583
4722
|
t,
|
|
4584
4723
|
`uuid()`,
|
|
4724
|
+
m,
|
|
4585
4725
|
// don't output the default default
|
|
4586
4726
|
data.default instanceof orchidCore.RawSQLBase && data.default._sql === uuidDefaultSQL ? __spreadProps$5(__spreadValues$9({}, data), { default: void 0 }) : data
|
|
4587
4727
|
);
|
|
@@ -4593,8 +4733,8 @@ class XMLColumn extends ColumnType {
|
|
|
4593
4733
|
this.dataType = "xml";
|
|
4594
4734
|
this.operators = Operators.text;
|
|
4595
4735
|
}
|
|
4596
|
-
toCode(t) {
|
|
4597
|
-
return columnCode(this, t, `xml()
|
|
4736
|
+
toCode(t, m) {
|
|
4737
|
+
return columnCode(this, t, `xml()`, m);
|
|
4598
4738
|
}
|
|
4599
4739
|
}
|
|
4600
4740
|
class CitextColumn extends TextBaseColumn {
|
|
@@ -4603,20 +4743,21 @@ class CitextColumn extends TextBaseColumn {
|
|
|
4603
4743
|
this.dataType = "citext";
|
|
4604
4744
|
setTextColumnData(this, min, max);
|
|
4605
4745
|
}
|
|
4606
|
-
toCode(t) {
|
|
4607
|
-
return textColumnToCode(this, t);
|
|
4746
|
+
toCode(t, m) {
|
|
4747
|
+
return textColumnToCode(this, t, m);
|
|
4608
4748
|
}
|
|
4609
4749
|
}
|
|
4610
4750
|
|
|
4611
4751
|
class BooleanColumn extends ColumnType {
|
|
4612
4752
|
constructor(schema) {
|
|
4613
4753
|
super(schema, schema.boolean());
|
|
4614
|
-
this.dataType = "
|
|
4754
|
+
this.dataType = "bool";
|
|
4615
4755
|
this.operators = Operators.boolean;
|
|
4616
4756
|
this.parseItem = (input) => input[0] === "t";
|
|
4757
|
+
this.data.alias = "boolean";
|
|
4617
4758
|
}
|
|
4618
|
-
toCode(t) {
|
|
4619
|
-
return columnCode(this, t, "boolean()");
|
|
4759
|
+
toCode(t, m) {
|
|
4760
|
+
return columnCode(this, t, "boolean()", m);
|
|
4620
4761
|
}
|
|
4621
4762
|
}
|
|
4622
4763
|
|
|
@@ -4632,8 +4773,8 @@ class CustomTypeColumn extends ColumnType {
|
|
|
4632
4773
|
this.operators = Operators.any;
|
|
4633
4774
|
this.data.isOfCustomType = true;
|
|
4634
4775
|
}
|
|
4635
|
-
toCode(t) {
|
|
4636
|
-
return columnCode(this, t, `type(${orchidCore.singleQuote(this.dataType)})
|
|
4776
|
+
toCode(t, m) {
|
|
4777
|
+
return columnCode(this, t, `type(${orchidCore.singleQuote(this.dataType)})`, m);
|
|
4637
4778
|
}
|
|
4638
4779
|
as(column) {
|
|
4639
4780
|
const c = orchidCore.setColumnData(
|
|
@@ -4648,8 +4789,8 @@ class CustomTypeColumn extends ColumnType {
|
|
|
4648
4789
|
}
|
|
4649
4790
|
}
|
|
4650
4791
|
class DomainColumn extends CustomTypeColumn {
|
|
4651
|
-
toCode(t) {
|
|
4652
|
-
return columnCode(this, t, `domain(${orchidCore.singleQuote(this.dataType)})
|
|
4792
|
+
toCode(t, m) {
|
|
4793
|
+
return columnCode(this, t, `domain(${orchidCore.singleQuote(this.dataType)})`, m);
|
|
4653
4794
|
}
|
|
4654
4795
|
}
|
|
4655
4796
|
|
|
@@ -4828,7 +4969,7 @@ const makeColumnTypes = (schema) => {
|
|
|
4828
4969
|
* See {@link ColumnType.searchIndex}
|
|
4829
4970
|
*/
|
|
4830
4971
|
searchIndex(columns, options) {
|
|
4831
|
-
return this.index(columns, __spreadProps$4(__spreadValues$8({}, options), { tsVector: true }));
|
|
4972
|
+
return this.index(columns, __spreadProps$4(__spreadValues$8({ using: "gin" }, options), { tsVector: true }));
|
|
4832
4973
|
},
|
|
4833
4974
|
constraint({ name, references, check, dropMode }) {
|
|
4834
4975
|
var _a;
|
|
@@ -4859,11 +5000,11 @@ const makeColumnTypes = (schema) => {
|
|
|
4859
5000
|
});
|
|
4860
5001
|
return orchidCore.emptyObject;
|
|
4861
5002
|
},
|
|
4862
|
-
check(check) {
|
|
5003
|
+
check(check, options) {
|
|
4863
5004
|
var _a;
|
|
4864
|
-
((_a = tableData.constraints) != null ? _a : tableData.constraints = []).push({
|
|
5005
|
+
((_a = tableData.constraints) != null ? _a : tableData.constraints = []).push(__spreadProps$4(__spreadValues$8({}, options), {
|
|
4865
5006
|
check
|
|
4866
|
-
});
|
|
5007
|
+
}));
|
|
4867
5008
|
return orchidCore.emptyObject;
|
|
4868
5009
|
}
|
|
4869
5010
|
}, orchidCore.makeTimestampsHelpers(makeRegexToFindInSql));
|
|
@@ -4982,6 +5123,8 @@ for (const key in types.builtins) {
|
|
|
4982
5123
|
delete defaultTypeParsers[id];
|
|
4983
5124
|
});
|
|
4984
5125
|
const returnArg = (arg) => arg;
|
|
5126
|
+
const rollbackSql$1 = { text: "ROLLBACK" };
|
|
5127
|
+
const commitSql$1 = { text: "COMMIT" };
|
|
4985
5128
|
class Adapter {
|
|
4986
5129
|
constructor(_a) {
|
|
4987
5130
|
var _b = _a, { types: types2 = defaultTypeParsers } = _b, config = __objRest$1(_b, ["types"]);
|
|
@@ -5023,7 +5166,7 @@ class Adapter {
|
|
|
5023
5166
|
arrays(query, types2) {
|
|
5024
5167
|
return performQuery$1(this, query, types2, "array");
|
|
5025
5168
|
}
|
|
5026
|
-
async transaction(begin, cb) {
|
|
5169
|
+
async transaction(begin, cb, end = commitSql$1) {
|
|
5027
5170
|
const client = await this.connect();
|
|
5028
5171
|
try {
|
|
5029
5172
|
await setSearchPath(client, this.schema);
|
|
@@ -5032,10 +5175,10 @@ class Adapter {
|
|
|
5032
5175
|
try {
|
|
5033
5176
|
result = await cb(new TransactionAdapter(this, client, this.types));
|
|
5034
5177
|
} catch (err) {
|
|
5035
|
-
await performQueryOnClient(client,
|
|
5178
|
+
await performQueryOnClient(client, rollbackSql$1, this.types);
|
|
5036
5179
|
throw err;
|
|
5037
5180
|
}
|
|
5038
|
-
await performQueryOnClient(client,
|
|
5181
|
+
await performQueryOnClient(client, end, this.types);
|
|
5039
5182
|
return result;
|
|
5040
5183
|
} finally {
|
|
5041
5184
|
client.release();
|
|
@@ -7953,7 +8096,7 @@ const makeMessage = (colors, timeColor, time, sqlColor, sql, valuesColor, values
|
|
|
7953
8096
|
const elapsed = process.hrtime(time);
|
|
7954
8097
|
const formattedTime = `(${elapsed[0] ? `${elapsed[0]}s ` : ""}${(elapsed[1] / 1e6).toFixed(1)}ms)`;
|
|
7955
8098
|
const result = `${colors ? timeColor(formattedTime) : formattedTime} ${colors ? sqlColor(sql) : sql}`;
|
|
7956
|
-
if (!values.length) {
|
|
8099
|
+
if (!(values == null ? void 0 : values.length)) {
|
|
7957
8100
|
return result;
|
|
7958
8101
|
}
|
|
7959
8102
|
const formattedValues = `[${values.map(quote).join(", ")}]`;
|
|
@@ -10911,21 +11054,23 @@ var __objRest = (source, exclude) => {
|
|
|
10911
11054
|
};
|
|
10912
11055
|
const anyShape = {};
|
|
10913
11056
|
class Db {
|
|
10914
|
-
constructor(adapter, queryBuilder, table = void 0, shape = anyShape, columnTypes, transactionStorage, options) {
|
|
11057
|
+
constructor(adapter, queryBuilder, table = void 0, shape = anyShape, columnTypes, transactionStorage, options, tableData = getTableData()) {
|
|
10915
11058
|
this.adapter = adapter;
|
|
10916
11059
|
this.queryBuilder = queryBuilder;
|
|
10917
11060
|
this.table = table;
|
|
10918
11061
|
this.shape = shape;
|
|
10919
11062
|
this.columnTypes = columnTypes;
|
|
11063
|
+
this.tableData = tableData;
|
|
10920
11064
|
var _a, _b;
|
|
10921
11065
|
const self = this;
|
|
10922
11066
|
const { softDelete } = options;
|
|
10923
11067
|
const scopes = options.scopes || softDelete ? {} : orchidCore.emptyObject;
|
|
10924
|
-
const tableData = getTableData();
|
|
10925
11068
|
this.internal = __spreadProps(__spreadValues({}, tableData), {
|
|
10926
11069
|
transactionStorage,
|
|
10927
11070
|
scopes,
|
|
10928
|
-
snakeCase: options.snakeCase
|
|
11071
|
+
snakeCase: options.snakeCase,
|
|
11072
|
+
noPrimaryKey: options.noPrimaryKey === "ignore",
|
|
11073
|
+
comment: options.comment
|
|
10929
11074
|
});
|
|
10930
11075
|
this.baseQuery = this;
|
|
10931
11076
|
const logger = options.logger || console;
|
|
@@ -10993,7 +11138,7 @@ class Db {
|
|
|
10993
11138
|
this.q.schema = options.schema;
|
|
10994
11139
|
}
|
|
10995
11140
|
this.primaryKeys = Object.keys(shape).filter(
|
|
10996
|
-
(key) => shape[key].data.
|
|
11141
|
+
(key) => shape[key].data.primaryKey
|
|
10997
11142
|
);
|
|
10998
11143
|
const primaryKeysFromData = (_b = getTableData().primaryKey) == null ? void 0 : _b.columns;
|
|
10999
11144
|
if (primaryKeysFromData)
|
|
@@ -11189,16 +11334,13 @@ const createDb = (_a) => {
|
|
|
11189
11334
|
ct[orchidCore.snakeCaseKey] = true;
|
|
11190
11335
|
}
|
|
11191
11336
|
const transactionStorage = new node_async_hooks.AsyncLocalStorage();
|
|
11192
|
-
const qb =
|
|
11337
|
+
const qb = _initQueryBuilder(
|
|
11193
11338
|
adapter,
|
|
11194
|
-
void 0,
|
|
11195
|
-
void 0,
|
|
11196
|
-
anyShape,
|
|
11197
11339
|
ct,
|
|
11198
11340
|
transactionStorage,
|
|
11199
|
-
commonOptions
|
|
11341
|
+
commonOptions,
|
|
11342
|
+
options
|
|
11200
11343
|
);
|
|
11201
|
-
qb.queryBuilder = qb;
|
|
11202
11344
|
const tableConstructor = (table, shape, options2) => new Db(
|
|
11203
11345
|
adapter,
|
|
11204
11346
|
qb,
|
|
@@ -11217,6 +11359,33 @@ const createDb = (_a) => {
|
|
|
11217
11359
|
}
|
|
11218
11360
|
return db;
|
|
11219
11361
|
};
|
|
11362
|
+
const _initQueryBuilder = (adapter, columnTypes, transactionStorage, commonOptions, options) => {
|
|
11363
|
+
const qb = new Db(
|
|
11364
|
+
adapter,
|
|
11365
|
+
void 0,
|
|
11366
|
+
void 0,
|
|
11367
|
+
anyShape,
|
|
11368
|
+
columnTypes,
|
|
11369
|
+
transactionStorage,
|
|
11370
|
+
commonOptions,
|
|
11371
|
+
orchidCore.emptyObject
|
|
11372
|
+
);
|
|
11373
|
+
if (options.extensions) {
|
|
11374
|
+
const arr = [];
|
|
11375
|
+
for (const x of options.extensions) {
|
|
11376
|
+
if (typeof x === "string") {
|
|
11377
|
+
arr.push({ name: x });
|
|
11378
|
+
} else {
|
|
11379
|
+
for (const key in x) {
|
|
11380
|
+
arr.push({ name: key, version: x[key] });
|
|
11381
|
+
}
|
|
11382
|
+
}
|
|
11383
|
+
}
|
|
11384
|
+
qb.internal.extensions = arr;
|
|
11385
|
+
}
|
|
11386
|
+
qb.internal.domains = options.domains;
|
|
11387
|
+
return qb.queryBuilder = qb;
|
|
11388
|
+
};
|
|
11220
11389
|
|
|
11221
11390
|
class Rollback extends Error {
|
|
11222
11391
|
}
|
|
@@ -11449,6 +11618,7 @@ exports.VirtualColumn = VirtualColumn;
|
|
|
11449
11618
|
exports.Where = Where;
|
|
11450
11619
|
exports.With = With;
|
|
11451
11620
|
exports.XMLColumn = XMLColumn;
|
|
11621
|
+
exports._initQueryBuilder = _initQueryBuilder;
|
|
11452
11622
|
exports._queryAfterSaveCommit = _queryAfterSaveCommit;
|
|
11453
11623
|
exports._queryAll = _queryAll;
|
|
11454
11624
|
exports._queryAs = _queryAs;
|
|
@@ -11516,6 +11686,7 @@ exports.columnCode = columnCode;
|
|
|
11516
11686
|
exports.columnForeignKeysToCode = columnForeignKeysToCode;
|
|
11517
11687
|
exports.columnIndexesToCode = columnIndexesToCode;
|
|
11518
11688
|
exports.columnsShapeToCode = columnsShapeToCode;
|
|
11689
|
+
exports.constraintInnerToCode = constraintInnerToCode;
|
|
11519
11690
|
exports.constraintPropsToCode = constraintPropsToCode;
|
|
11520
11691
|
exports.constraintToCode = constraintToCode;
|
|
11521
11692
|
exports.copyTableData = copyTableData;
|
|
@@ -11533,6 +11704,7 @@ exports.getShapeFromSelect = getShapeFromSelect;
|
|
|
11533
11704
|
exports.getTableData = getTableData;
|
|
11534
11705
|
exports.handleResult = handleResult;
|
|
11535
11706
|
exports.identityToCode = identityToCode;
|
|
11707
|
+
exports.indexInnerToCode = indexInnerToCode;
|
|
11536
11708
|
exports.indexToCode = indexToCode;
|
|
11537
11709
|
exports.instantiateColumn = instantiateColumn;
|
|
11538
11710
|
exports.isDefaultTimeStamp = isDefaultTimeStamp;
|
|
@@ -11550,6 +11722,7 @@ exports.makeSQL = makeSQL;
|
|
|
11550
11722
|
exports.newTableData = newTableData;
|
|
11551
11723
|
exports.parseRecord = parseRecord;
|
|
11552
11724
|
exports.parseResult = parseResult;
|
|
11725
|
+
exports.primaryKeyInnerToCode = primaryKeyInnerToCode;
|
|
11553
11726
|
exports.primaryKeyToCode = primaryKeyToCode;
|
|
11554
11727
|
exports.processSelectArg = processSelectArg;
|
|
11555
11728
|
exports.pushLimitSQL = pushLimitSQL;
|