pqb 0.11.18 → 0.11.19
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 +3 -2
- package/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -837,6 +837,7 @@ type DbOptions<CT extends ColumnTypesBase> = ({
|
|
|
837
837
|
autoPreparedStatements?: boolean;
|
|
838
838
|
noPrimaryKey?: NoPrimaryKeyOption;
|
|
839
839
|
snakeCase?: boolean;
|
|
840
|
+
nowSQL?: string;
|
|
840
841
|
};
|
|
841
842
|
type DbTableOptions = {
|
|
842
843
|
schema?: string;
|
|
@@ -884,7 +885,7 @@ type DbResult<CT extends ColumnTypesBase> = Db<string, Record<string, never>, Qu
|
|
|
884
885
|
adapter: Adapter;
|
|
885
886
|
close: Adapter['close'];
|
|
886
887
|
};
|
|
887
|
-
declare const createDb: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>>({ log, logger, columnTypes: ctOrFn, snakeCase, ...options }: DbOptions<CT>) => DbResult<CT>;
|
|
888
|
+
declare const createDb: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>>({ log, logger, columnTypes: ctOrFn, snakeCase, nowSQL, ...options }: DbOptions<CT>) => DbResult<CT>;
|
|
888
889
|
|
|
889
890
|
type WithArgsOptions = Omit<WithOptions, 'columns'> & {
|
|
890
891
|
columns?: boolean | string[];
|
|
@@ -3408,7 +3409,7 @@ declare const getConstraintKind: (it: TableData.Constraint) => 'constraint' | 'f
|
|
|
3408
3409
|
declare const newTableData: () => TableData;
|
|
3409
3410
|
declare const getTableData: () => TableData;
|
|
3410
3411
|
declare const resetTableData: (data?: TableData) => void;
|
|
3411
|
-
declare const getColumnTypes: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>, Shape extends ColumnsShape>(types: CT, fn: (t: CT) => Shape, data?: TableData) => Shape;
|
|
3412
|
+
declare const getColumnTypes: <CT extends Record<string, orchid_core.AnyColumnTypeCreator>, Shape extends ColumnsShape>(types: CT, fn: (t: CT) => Shape, nowSQL: string | undefined, data?: TableData) => Shape;
|
|
3412
3413
|
declare function text(min: number, max: number): TextColumn;
|
|
3413
3414
|
type DefaultColumnTypes = typeof columnTypes;
|
|
3414
3415
|
declare const columnTypes: {
|
package/dist/index.js
CHANGED
|
@@ -377,7 +377,7 @@ const isDefaultTimeStamp = (item) => {
|
|
|
377
377
|
if (item.dataType !== "timestamptz")
|
|
378
378
|
return false;
|
|
379
379
|
const def = item.data.default;
|
|
380
|
-
return def && orchidCore.isRaw(def) && def.__raw
|
|
380
|
+
return def && orchidCore.isRaw(def) && def.__raw.startsWith("now()");
|
|
381
381
|
};
|
|
382
382
|
const combineCodeElements = (input) => {
|
|
383
383
|
if (typeof input === "string")
|
|
@@ -3249,7 +3249,9 @@ const getTableData = () => tableData;
|
|
|
3249
3249
|
const resetTableData = (data = newTableData()) => {
|
|
3250
3250
|
tableData = data;
|
|
3251
3251
|
};
|
|
3252
|
-
const getColumnTypes = (types, fn, data = newTableData()) => {
|
|
3252
|
+
const getColumnTypes = (types, fn, nowSQL, data = newTableData()) => {
|
|
3253
|
+
if (nowSQL)
|
|
3254
|
+
orchidCore.setDefaultNowFn(nowSQL);
|
|
3253
3255
|
resetTableData(data);
|
|
3254
3256
|
return fn(types);
|
|
3255
3257
|
};
|
|
@@ -3465,9 +3467,9 @@ const columnTypes = __spreadValues$9({
|
|
|
3465
3467
|
}
|
|
3466
3468
|
}, orchidCore.makeTimestampsHelpers(
|
|
3467
3469
|
makeRegexToFindInSql('\\bupdatedAt\\b"?\\s*='),
|
|
3468
|
-
|
|
3470
|
+
'"updatedAt"',
|
|
3469
3471
|
makeRegexToFindInSql('\\bupdated_at\\b"?\\s*='),
|
|
3470
|
-
|
|
3472
|
+
'"updated_at"'
|
|
3471
3473
|
));
|
|
3472
3474
|
|
|
3473
3475
|
class ColumnsObject extends ColumnType {
|
|
@@ -6552,12 +6554,14 @@ const createDb = (_a) => {
|
|
|
6552
6554
|
log,
|
|
6553
6555
|
logger,
|
|
6554
6556
|
columnTypes: ctOrFn = columnTypes,
|
|
6555
|
-
snakeCase
|
|
6557
|
+
snakeCase,
|
|
6558
|
+
nowSQL
|
|
6556
6559
|
} = _b, options = __objRest(_b, [
|
|
6557
6560
|
"log",
|
|
6558
6561
|
"logger",
|
|
6559
6562
|
"columnTypes",
|
|
6560
|
-
"snakeCase"
|
|
6563
|
+
"snakeCase",
|
|
6564
|
+
"nowSQL"
|
|
6561
6565
|
]);
|
|
6562
6566
|
var _a2, _b2;
|
|
6563
6567
|
const adapter = "adapter" in options ? options.adapter : new Adapter(options);
|
|
@@ -6589,7 +6593,7 @@ const createDb = (_a) => {
|
|
|
6589
6593
|
adapter,
|
|
6590
6594
|
qb,
|
|
6591
6595
|
table,
|
|
6592
|
-
typeof shape === "function" ? getColumnTypes(ct, shape) : shape,
|
|
6596
|
+
typeof shape === "function" ? getColumnTypes(ct, shape, nowSQL) : shape,
|
|
6593
6597
|
ct,
|
|
6594
6598
|
transactionStorage,
|
|
6595
6599
|
__spreadValues(__spreadValues({}, commonOptions), options2)
|