pqb 0.40.12 → 0.41.1
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 +17 -28
- package/dist/index.js +212 -192
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +208 -193
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -117,21 +117,21 @@ const sqlFn = (...args) => {
|
|
|
117
117
|
return (...args2) => new RawSQL(args2, arg);
|
|
118
118
|
};
|
|
119
119
|
|
|
120
|
-
var __defProp$
|
|
120
|
+
var __defProp$o = Object.defineProperty;
|
|
121
121
|
var __defProps$e = Object.defineProperties;
|
|
122
122
|
var __getOwnPropDescs$e = Object.getOwnPropertyDescriptors;
|
|
123
|
-
var __getOwnPropSymbols$
|
|
124
|
-
var __hasOwnProp$
|
|
125
|
-
var __propIsEnum$
|
|
126
|
-
var __defNormalProp$
|
|
127
|
-
var __spreadValues$
|
|
123
|
+
var __getOwnPropSymbols$p = Object.getOwnPropertySymbols;
|
|
124
|
+
var __hasOwnProp$p = Object.prototype.hasOwnProperty;
|
|
125
|
+
var __propIsEnum$p = Object.prototype.propertyIsEnumerable;
|
|
126
|
+
var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
127
|
+
var __spreadValues$o = (a, b) => {
|
|
128
128
|
for (var prop in b || (b = {}))
|
|
129
|
-
if (__hasOwnProp$
|
|
130
|
-
__defNormalProp$
|
|
131
|
-
if (__getOwnPropSymbols$
|
|
132
|
-
for (var prop of __getOwnPropSymbols$
|
|
133
|
-
if (__propIsEnum$
|
|
134
|
-
__defNormalProp$
|
|
129
|
+
if (__hasOwnProp$p.call(b, prop))
|
|
130
|
+
__defNormalProp$o(a, prop, b[prop]);
|
|
131
|
+
if (__getOwnPropSymbols$p)
|
|
132
|
+
for (var prop of __getOwnPropSymbols$p(b)) {
|
|
133
|
+
if (__propIsEnum$p.call(b, prop))
|
|
134
|
+
__defNormalProp$o(a, prop, b[prop]);
|
|
135
135
|
}
|
|
136
136
|
return a;
|
|
137
137
|
};
|
|
@@ -334,13 +334,13 @@ class ColumnType extends ColumnTypeBase {
|
|
|
334
334
|
*/
|
|
335
335
|
searchIndex(...args) {
|
|
336
336
|
return pushColumnData(this, "indexes", {
|
|
337
|
-
options: __spreadValues$
|
|
337
|
+
options: __spreadValues$o(__spreadValues$o({}, typeof args[0] === "string" ? args[1] : args[0]), this.dataType === "tsvector" ? { using: "GIN" } : { tsVector: true }),
|
|
338
338
|
name: typeof args[0] === "string" ? args[0] : void 0
|
|
339
339
|
});
|
|
340
340
|
}
|
|
341
341
|
unique(...args) {
|
|
342
342
|
return pushColumnData(this, "indexes", {
|
|
343
|
-
options: __spreadProps$e(__spreadValues$
|
|
343
|
+
options: __spreadProps$e(__spreadValues$o({}, typeof args[0] === "string" ? args[1] : args[0]), {
|
|
344
344
|
unique: true
|
|
345
345
|
}),
|
|
346
346
|
name: typeof args[0] === "string" ? args[0] : void 0
|
|
@@ -383,21 +383,21 @@ class ColumnType extends ColumnTypeBase {
|
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
385
|
|
|
386
|
-
var __defProp$
|
|
386
|
+
var __defProp$n = Object.defineProperty;
|
|
387
387
|
var __defProps$d = Object.defineProperties;
|
|
388
388
|
var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
|
|
389
|
-
var __getOwnPropSymbols$
|
|
390
|
-
var __hasOwnProp$
|
|
391
|
-
var __propIsEnum$
|
|
392
|
-
var __defNormalProp$
|
|
393
|
-
var __spreadValues$
|
|
389
|
+
var __getOwnPropSymbols$o = Object.getOwnPropertySymbols;
|
|
390
|
+
var __hasOwnProp$o = Object.prototype.hasOwnProperty;
|
|
391
|
+
var __propIsEnum$o = Object.prototype.propertyIsEnumerable;
|
|
392
|
+
var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
393
|
+
var __spreadValues$n = (a, b) => {
|
|
394
394
|
for (var prop in b || (b = {}))
|
|
395
|
-
if (__hasOwnProp$
|
|
396
|
-
__defNormalProp$
|
|
397
|
-
if (__getOwnPropSymbols$
|
|
398
|
-
for (var prop of __getOwnPropSymbols$
|
|
399
|
-
if (__propIsEnum$
|
|
400
|
-
__defNormalProp$
|
|
395
|
+
if (__hasOwnProp$o.call(b, prop))
|
|
396
|
+
__defNormalProp$n(a, prop, b[prop]);
|
|
397
|
+
if (__getOwnPropSymbols$o)
|
|
398
|
+
for (var prop of __getOwnPropSymbols$o(b)) {
|
|
399
|
+
if (__propIsEnum$o.call(b, prop))
|
|
400
|
+
__defNormalProp$n(a, prop, b[prop]);
|
|
401
401
|
}
|
|
402
402
|
return a;
|
|
403
403
|
};
|
|
@@ -417,7 +417,7 @@ const simplifyColumnDefault = (value) => {
|
|
|
417
417
|
const instantiateColumn = (typeFn, params) => {
|
|
418
418
|
const column = typeFn();
|
|
419
419
|
const { dateTimePrecision } = params;
|
|
420
|
-
Object.assign(column.data, __spreadProps$d(__spreadValues$
|
|
420
|
+
Object.assign(column.data, __spreadProps$d(__spreadValues$n({}, params), {
|
|
421
421
|
dateTimePrecision: (
|
|
422
422
|
// 0 is default for date, 6 is default for timestamp
|
|
423
423
|
dateTimePrecision && dateTimePrecision !== 6 ? dateTimePrecision : void 0
|
|
@@ -775,8 +775,9 @@ const identityToCode = (identity, dataType) => {
|
|
|
775
775
|
addCode(code, ")");
|
|
776
776
|
return code;
|
|
777
777
|
};
|
|
778
|
-
const columnCode = (type, ctx, key, code
|
|
778
|
+
const columnCode = (type, ctx, key, code) => {
|
|
779
779
|
var _a;
|
|
780
|
+
const { data } = type;
|
|
780
781
|
code = toArray(code);
|
|
781
782
|
let prepend = `${ctx.t}.`;
|
|
782
783
|
const keyName = ctx.snakeCase ? toSnakeCase(key) : key;
|
|
@@ -807,13 +808,15 @@ const columnCode = (type, ctx, key, code, data = type.data, skip) => {
|
|
|
807
808
|
addCode(code, ".select(false)");
|
|
808
809
|
if (data.isNullable)
|
|
809
810
|
addCode(code, ".nullable()");
|
|
810
|
-
if (
|
|
811
|
-
addCode(code, `.encode(${
|
|
812
|
-
if (
|
|
813
|
-
addCode(code, `.parse(${
|
|
811
|
+
if (data.encode && data.encode !== data.defaultEncode)
|
|
812
|
+
addCode(code, `.encode(${data.encode.toString()})`);
|
|
813
|
+
if (data.parse && data.parse !== data.defaultParse)
|
|
814
|
+
addCode(code, `.parse(${data.parse.toString()})`);
|
|
815
|
+
if (type.data.parseNull)
|
|
816
|
+
addCode(code, `.parseNull(${type.data.parseNull.toString()})`);
|
|
814
817
|
if (data.as)
|
|
815
818
|
addCode(code, `.as(${data.as.toCode(ctx, key)})`);
|
|
816
|
-
if (data.default !== void 0 && (!ctx.migration || typeof data.default !== "function")) {
|
|
819
|
+
if (data.default !== void 0 && data.default !== data.defaultDefault && (!ctx.migration || typeof data.default !== "function")) {
|
|
817
820
|
addCode(
|
|
818
821
|
code,
|
|
819
822
|
`.default(${columnDefaultArgumentToCode(ctx.t, data.default)})`
|
|
@@ -856,9 +859,61 @@ const getSqlText = (sql) => {
|
|
|
856
859
|
throw new Error(`Batch SQL is not supported in this query`);
|
|
857
860
|
};
|
|
858
861
|
|
|
859
|
-
var __defProp$
|
|
862
|
+
var __defProp$m = Object.defineProperty;
|
|
860
863
|
var __defProps$c = Object.defineProperties;
|
|
861
864
|
var __getOwnPropDescs$c = Object.getOwnPropertyDescriptors;
|
|
865
|
+
var __getOwnPropSymbols$n = Object.getOwnPropertySymbols;
|
|
866
|
+
var __hasOwnProp$n = Object.prototype.hasOwnProperty;
|
|
867
|
+
var __propIsEnum$n = Object.prototype.propertyIsEnumerable;
|
|
868
|
+
var __defNormalProp$m = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
869
|
+
var __spreadValues$m = (a, b) => {
|
|
870
|
+
for (var prop in b || (b = {}))
|
|
871
|
+
if (__hasOwnProp$n.call(b, prop))
|
|
872
|
+
__defNormalProp$m(a, prop, b[prop]);
|
|
873
|
+
if (__getOwnPropSymbols$n)
|
|
874
|
+
for (var prop of __getOwnPropSymbols$n(b)) {
|
|
875
|
+
if (__propIsEnum$n.call(b, prop))
|
|
876
|
+
__defNormalProp$m(a, prop, b[prop]);
|
|
877
|
+
}
|
|
878
|
+
return a;
|
|
879
|
+
};
|
|
880
|
+
var __spreadProps$c = (a, b) => __defProps$c(a, __getOwnPropDescs$c(b));
|
|
881
|
+
const addColumnParserToQuery = (q, key, column) => {
|
|
882
|
+
var _a;
|
|
883
|
+
if (column._parse) {
|
|
884
|
+
((_a = q.parsers) != null ? _a : q.parsers = {})[key] = column._parse;
|
|
885
|
+
}
|
|
886
|
+
};
|
|
887
|
+
const setColumnDefaultParse = (column, parse) => {
|
|
888
|
+
column.data.parse = column.data.defaultParse = parse;
|
|
889
|
+
column._parse = (input) => input === null ? null : parse(input);
|
|
890
|
+
};
|
|
891
|
+
const setColumnParse = (column, fn, outputSchema) => {
|
|
892
|
+
const c = Object.create(column);
|
|
893
|
+
c.outputSchema = outputSchema;
|
|
894
|
+
c.data = __spreadProps$c(__spreadValues$m({}, column.data), { parse: fn });
|
|
895
|
+
const { parseNull } = column.data;
|
|
896
|
+
c._parse = parseNull ? (input) => input === null ? parseNull() : fn(input) : (input) => input === null ? null : fn(input);
|
|
897
|
+
return c;
|
|
898
|
+
};
|
|
899
|
+
const setColumnParseNull = (column, fn, nullSchema) => {
|
|
900
|
+
const c = Object.create(column);
|
|
901
|
+
c.nullSchema = nullSchema;
|
|
902
|
+
c.data = __spreadProps$c(__spreadValues$m({}, column.data), { parseNull: fn });
|
|
903
|
+
const { parse } = column.data;
|
|
904
|
+
c._parse = parse ? (input) => input === null ? fn() : parse(input) : (input) => input === null ? fn() : input;
|
|
905
|
+
return c;
|
|
906
|
+
};
|
|
907
|
+
const setColumnEncode = (column, fn, inputSchema) => {
|
|
908
|
+
const c = Object.create(column);
|
|
909
|
+
c.inputSchema = inputSchema;
|
|
910
|
+
c.data = __spreadProps$c(__spreadValues$m({}, column.data), { encode: fn });
|
|
911
|
+
return c;
|
|
912
|
+
};
|
|
913
|
+
|
|
914
|
+
var __defProp$l = Object.defineProperty;
|
|
915
|
+
var __defProps$b = Object.defineProperties;
|
|
916
|
+
var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
|
|
862
917
|
var __getOwnPropSymbols$m = Object.getOwnPropertySymbols;
|
|
863
918
|
var __hasOwnProp$m = Object.prototype.hasOwnProperty;
|
|
864
919
|
var __propIsEnum$m = Object.prototype.propertyIsEnumerable;
|
|
@@ -874,7 +929,7 @@ var __spreadValues$l = (a, b) => {
|
|
|
874
929
|
}
|
|
875
930
|
return a;
|
|
876
931
|
};
|
|
877
|
-
var __spreadProps$
|
|
932
|
+
var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
|
|
878
933
|
function setQueryOperators(query, operators) {
|
|
879
934
|
const q = query.q;
|
|
880
935
|
if (q.operators !== operators) {
|
|
@@ -963,7 +1018,7 @@ const base = {
|
|
|
963
1018
|
(key, value, ctx, quotedAs) => `NOT ${key} IN ${quoteValue(value, ctx, quotedAs)}`
|
|
964
1019
|
)
|
|
965
1020
|
};
|
|
966
|
-
const boolean = __spreadProps$
|
|
1021
|
+
const boolean = __spreadProps$b(__spreadValues$l({}, base), {
|
|
967
1022
|
and: make(
|
|
968
1023
|
(key, value, ctx, quotedAs) => `${key} AND ${value.q.expr.toSQL(ctx, quotedAs)}`
|
|
969
1024
|
),
|
|
@@ -971,7 +1026,7 @@ const boolean = __spreadProps$c(__spreadValues$l({}, base), {
|
|
|
971
1026
|
(key, value, ctx, quotedAs) => `(${key}) OR (${value.q.expr.toSQL(ctx, quotedAs)})`
|
|
972
1027
|
)
|
|
973
1028
|
});
|
|
974
|
-
const numeric = __spreadProps$
|
|
1029
|
+
const numeric = __spreadProps$b(__spreadValues$l({}, base), {
|
|
975
1030
|
lt: make(
|
|
976
1031
|
(key, value, ctx, quotedAs) => `${key} < ${quoteValue(value, ctx, quotedAs)}`
|
|
977
1032
|
),
|
|
@@ -992,7 +1047,7 @@ const numeric = __spreadProps$c(__spreadValues$l({}, base), {
|
|
|
992
1047
|
)}`
|
|
993
1048
|
)
|
|
994
1049
|
});
|
|
995
|
-
const text = __spreadProps$
|
|
1050
|
+
const text = __spreadProps$b(__spreadValues$l({}, base), {
|
|
996
1051
|
contains: make(
|
|
997
1052
|
(key, value, ctx, quotedAs) => `${key} ILIKE '%' || ${quoteLikeValue(value, ctx, quotedAs)} || '%'`
|
|
998
1053
|
),
|
|
@@ -1014,10 +1069,10 @@ const text = __spreadProps$c(__spreadValues$l({}, base), {
|
|
|
1014
1069
|
});
|
|
1015
1070
|
const encodeJsonPath = (ctx, path) => addValue(ctx.values, `{${Array.isArray(path) ? path.join(", ") : path}}`);
|
|
1016
1071
|
const jsonPathQueryOp = (key, [path, options], ctx) => `jsonb_path_query_first(${key}, ${addValue(ctx.values, path)}${(options == null ? void 0 : options.vars) ? `, ${addValue(ctx.values, JSON.stringify(options.vars))}${options.silent ? ", true" : ""}` : (options == null ? void 0 : options.silent) ? ", NULL, true" : ""})`;
|
|
1017
|
-
const json = __spreadProps$
|
|
1072
|
+
const json = __spreadProps$b(__spreadValues$l({}, base), {
|
|
1018
1073
|
jsonPathQueryFirst: Object.assign(
|
|
1019
1074
|
function(path, options) {
|
|
1020
|
-
var _a, _b, _c
|
|
1075
|
+
var _a, _b, _c;
|
|
1021
1076
|
const chain = (_b = (_a = this.q).chain) != null ? _b : _a.chain = [];
|
|
1022
1077
|
chain.push(jsonPathQueryOp, [path, options]);
|
|
1023
1078
|
if ((_c = this.q.parsers) == null ? void 0 : _c[getValueKey]) {
|
|
@@ -1025,8 +1080,7 @@ const json = __spreadProps$c(__spreadValues$l({}, base), {
|
|
|
1025
1080
|
}
|
|
1026
1081
|
if (options == null ? void 0 : options.type) {
|
|
1027
1082
|
const type = options.type(this.columnTypes);
|
|
1028
|
-
|
|
1029
|
-
((_e = (_d = this.q).parsers) != null ? _e : _d.parsers = {})[getValueKey] = type.parseFn;
|
|
1083
|
+
addColumnParserToQuery(this.q, getValueKey, type);
|
|
1030
1084
|
chain.push = (...args) => {
|
|
1031
1085
|
chain.push = Array.prototype.push;
|
|
1032
1086
|
chain.push((s) => `${s}::${type.dataType}`, emptyArray);
|
|
@@ -1078,8 +1132,6 @@ const Operators = {
|
|
|
1078
1132
|
};
|
|
1079
1133
|
|
|
1080
1134
|
var __defProp$k = Object.defineProperty;
|
|
1081
|
-
var __defProps$b = Object.defineProperties;
|
|
1082
|
-
var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
|
|
1083
1135
|
var __getOwnPropSymbols$l = Object.getOwnPropertySymbols;
|
|
1084
1136
|
var __hasOwnProp$l = Object.prototype.hasOwnProperty;
|
|
1085
1137
|
var __propIsEnum$l = Object.prototype.propertyIsEnumerable;
|
|
@@ -1095,7 +1147,6 @@ var __spreadValues$k = (a, b) => {
|
|
|
1095
1147
|
}
|
|
1096
1148
|
return a;
|
|
1097
1149
|
};
|
|
1098
|
-
var __spreadProps$b = (a, b) => __defProps$b(a, __getOwnPropDescs$b(b));
|
|
1099
1150
|
class TextBaseColumn extends ColumnType {
|
|
1100
1151
|
constructor(schema, schemaType = schema.stringSchema()) {
|
|
1101
1152
|
super(schema, schemaType);
|
|
@@ -1265,19 +1316,20 @@ class MoneyColumn extends ColumnType {
|
|
|
1265
1316
|
super(schema, schema.number());
|
|
1266
1317
|
this.dataType = "money";
|
|
1267
1318
|
this.operators = Operators.number;
|
|
1268
|
-
this
|
|
1269
|
-
function(input) {
|
|
1270
|
-
return input === null ? input : parseFloat(input.replace(/,/g, "").replace(/\$/g, ""));
|
|
1271
|
-
},
|
|
1272
|
-
{
|
|
1273
|
-
hideFromCode: true
|
|
1274
|
-
}
|
|
1275
|
-
);
|
|
1319
|
+
setColumnDefaultParse(this, moneyParse);
|
|
1276
1320
|
}
|
|
1277
1321
|
toCode(ctx, key) {
|
|
1278
1322
|
return columnCode(this, ctx, key, `money()`);
|
|
1279
1323
|
}
|
|
1280
1324
|
}
|
|
1325
|
+
const moneyParse = Object.assign(
|
|
1326
|
+
function(input) {
|
|
1327
|
+
return input === null ? input : parseFloat(input.replace(/,/g, "").replace(/\$/g, ""));
|
|
1328
|
+
},
|
|
1329
|
+
{
|
|
1330
|
+
hideFromCode: true
|
|
1331
|
+
}
|
|
1332
|
+
);
|
|
1281
1333
|
class CidrColumn extends ColumnType {
|
|
1282
1334
|
constructor(schema) {
|
|
1283
1335
|
super(schema, schema.stringSchema());
|
|
@@ -1436,6 +1488,7 @@ class UUIDColumn extends ColumnType {
|
|
|
1436
1488
|
super(schema, schema.uuid());
|
|
1437
1489
|
this.dataType = "uuid";
|
|
1438
1490
|
this.operators = Operators.text;
|
|
1491
|
+
this.data.defaultDefault = uuidDefault;
|
|
1439
1492
|
}
|
|
1440
1493
|
/**
|
|
1441
1494
|
* see {@link ColumnType.primaryKey}
|
|
@@ -1447,15 +1500,7 @@ class UUIDColumn extends ColumnType {
|
|
|
1447
1500
|
return column;
|
|
1448
1501
|
}
|
|
1449
1502
|
toCode(ctx, key) {
|
|
1450
|
-
|
|
1451
|
-
return columnCode(
|
|
1452
|
-
this,
|
|
1453
|
-
ctx,
|
|
1454
|
-
key,
|
|
1455
|
-
`uuid()`,
|
|
1456
|
-
// don't output the default default
|
|
1457
|
-
data.default instanceof RawSQLBase && data.default._sql === uuidDefaultSQL ? __spreadProps$b(__spreadValues$k({}, data), { default: void 0 }) : data
|
|
1458
|
-
);
|
|
1503
|
+
return columnCode(this, ctx, key, `uuid()`);
|
|
1459
1504
|
}
|
|
1460
1505
|
}
|
|
1461
1506
|
class XMLColumn extends ColumnType {
|
|
@@ -1482,7 +1527,6 @@ class CitextColumn extends TextBaseColumn {
|
|
|
1482
1527
|
const dateTimeEncode = (input) => {
|
|
1483
1528
|
return typeof input === "number" ? new Date(input) : input;
|
|
1484
1529
|
};
|
|
1485
|
-
const skipDateMethodsFromToCode = { encodeFn: dateTimeEncode };
|
|
1486
1530
|
class DateBaseColumn extends ColumnType {
|
|
1487
1531
|
constructor(schema) {
|
|
1488
1532
|
super(
|
|
@@ -1492,9 +1536,9 @@ class DateBaseColumn extends ColumnType {
|
|
|
1492
1536
|
schema.stringNumberDate()
|
|
1493
1537
|
);
|
|
1494
1538
|
this.operators = Operators.date;
|
|
1495
|
-
this.encodeFn = dateTimeEncode;
|
|
1496
1539
|
this.asNumber = schema.dateAsNumber;
|
|
1497
1540
|
this.asDate = schema.dateAsDate;
|
|
1541
|
+
this.data.encode = this.data.defaultEncode = dateTimeEncode;
|
|
1498
1542
|
}
|
|
1499
1543
|
}
|
|
1500
1544
|
class DateColumn extends DateBaseColumn {
|
|
@@ -1507,9 +1551,7 @@ class DateColumn extends DateBaseColumn {
|
|
|
1507
1551
|
this,
|
|
1508
1552
|
ctx,
|
|
1509
1553
|
key,
|
|
1510
|
-
`date()${dateDataToCode(this.data, ctx.migration)}
|
|
1511
|
-
this.data,
|
|
1512
|
-
skipDateMethodsFromToCode
|
|
1554
|
+
`date()${dateDataToCode(this.data, ctx.migration)}`
|
|
1513
1555
|
);
|
|
1514
1556
|
}
|
|
1515
1557
|
}
|
|
@@ -1547,9 +1589,7 @@ const timestampToCode = (self, ctx, key) => {
|
|
|
1547
1589
|
self,
|
|
1548
1590
|
ctx,
|
|
1549
1591
|
key,
|
|
1550
|
-
`timestamps${noTz}(${p && p !== 6 ? p : ""}).${defaultTimestamp}${dateDataToCode(self.data, ctx.migration)}
|
|
1551
|
-
self.data,
|
|
1552
|
-
skipDateMethodsFromToCode
|
|
1592
|
+
`timestamps${noTz}(${p && p !== 6 ? p : ""}).${defaultTimestamp}${dateDataToCode(self.data, ctx.migration)}`
|
|
1553
1593
|
);
|
|
1554
1594
|
self.data.default = def;
|
|
1555
1595
|
self.data.modifyQuery = modifyQuery;
|
|
@@ -1559,9 +1599,7 @@ const timestampToCode = (self, ctx, key) => {
|
|
|
1559
1599
|
self,
|
|
1560
1600
|
ctx,
|
|
1561
1601
|
key,
|
|
1562
|
-
`${self instanceof TimestampColumn ? "timestampNoTZ" : "timestamp"}(${p && p !== 6 ? p : ""})${dateDataToCode(self.data, ctx.migration)}
|
|
1563
|
-
self.data,
|
|
1564
|
-
skipDateMethodsFromToCode
|
|
1602
|
+
`${self instanceof TimestampColumn ? "timestampNoTZ" : "timestamp"}(${p && p !== 6 ? p : ""})${dateDataToCode(self.data, ctx.migration)}`
|
|
1565
1603
|
);
|
|
1566
1604
|
}
|
|
1567
1605
|
};
|
|
@@ -1600,9 +1638,7 @@ class TimeColumn extends ColumnType {
|
|
|
1600
1638
|
`time(${dateTimePrecision || ""})${dateDataToCode(
|
|
1601
1639
|
this.data,
|
|
1602
1640
|
ctx.migration
|
|
1603
|
-
)}
|
|
1604
|
-
this.data,
|
|
1605
|
-
skipDateMethodsFromToCode
|
|
1641
|
+
)}`
|
|
1606
1642
|
);
|
|
1607
1643
|
}
|
|
1608
1644
|
}
|
|
@@ -1620,9 +1656,7 @@ class IntervalColumn extends ColumnType {
|
|
|
1620
1656
|
this,
|
|
1621
1657
|
ctx,
|
|
1622
1658
|
key,
|
|
1623
|
-
`interval(${[fields && `'${fields}'`, precision && String(precision)].filter((part) => part).join(", ")})
|
|
1624
|
-
this.data,
|
|
1625
|
-
skipDateMethodsFromToCode
|
|
1659
|
+
`interval(${[fields && `'${fields}'`, precision && String(precision)].filter((part) => part).join(", ")})`
|
|
1626
1660
|
);
|
|
1627
1661
|
}
|
|
1628
1662
|
toSQL() {
|
|
@@ -1640,28 +1674,26 @@ class BooleanColumn extends ColumnType {
|
|
|
1640
1674
|
this.dataType = "bool";
|
|
1641
1675
|
this.operators = Operators.boolean;
|
|
1642
1676
|
this.data.alias = "boolean";
|
|
1677
|
+
this.data.parseItem = parseItem;
|
|
1643
1678
|
}
|
|
1644
1679
|
toCode(ctx, key) {
|
|
1645
1680
|
return columnCode(this, ctx, key, "boolean()");
|
|
1646
1681
|
}
|
|
1647
|
-
parseItem(input) {
|
|
1648
|
-
return input[0] === "t";
|
|
1649
|
-
}
|
|
1650
1682
|
}
|
|
1683
|
+
const parseItem = (input) => input[0] === "t";
|
|
1651
1684
|
|
|
1652
|
-
const
|
|
1653
|
-
const toCodeSkip = { encodeFn };
|
|
1685
|
+
const encode = (x) => x === null ? x : JSON.stringify(x);
|
|
1654
1686
|
class JSONColumn extends ColumnType {
|
|
1655
|
-
constructor() {
|
|
1656
|
-
super(
|
|
1687
|
+
constructor(schema, inputType) {
|
|
1688
|
+
super(schema, inputType);
|
|
1657
1689
|
this.dataType = "jsonb";
|
|
1658
1690
|
this.operators = Operators.json;
|
|
1691
|
+
this.data.encode = this.data.defaultEncode = encode;
|
|
1659
1692
|
}
|
|
1660
1693
|
toCode(ctx, key) {
|
|
1661
|
-
return columnCode(this, ctx, key, `json()
|
|
1694
|
+
return columnCode(this, ctx, key, `json()`);
|
|
1662
1695
|
}
|
|
1663
1696
|
}
|
|
1664
|
-
JSONColumn.prototype.encodeFn = encodeFn;
|
|
1665
1697
|
class JSONTextColumn extends ColumnType {
|
|
1666
1698
|
constructor(schema) {
|
|
1667
1699
|
super(schema, schema.stringSchema());
|
|
@@ -1669,7 +1701,7 @@ class JSONTextColumn extends ColumnType {
|
|
|
1669
1701
|
this.operators = Operators.text;
|
|
1670
1702
|
}
|
|
1671
1703
|
toCode(ctx, key) {
|
|
1672
|
-
return columnCode(this, ctx, key, `jsonText()
|
|
1704
|
+
return columnCode(this, ctx, key, `jsonText()`);
|
|
1673
1705
|
}
|
|
1674
1706
|
}
|
|
1675
1707
|
|
|
@@ -1682,10 +1714,7 @@ const queryTypeWithLimitOne = {
|
|
|
1682
1714
|
const isQueryReturnsAll = (q) => !q.q.returnType || q.q.returnType === "all";
|
|
1683
1715
|
|
|
1684
1716
|
const applySqlComputed = (ctx, q, computed, as, quotedAs) => {
|
|
1685
|
-
|
|
1686
|
-
const parser = computed.result.value.parseFn;
|
|
1687
|
-
if (parser)
|
|
1688
|
-
((_a = q.parsers) != null ? _a : q.parsers = {})[as] = parser;
|
|
1717
|
+
addColumnParserToQuery(q, as, computed.result.value);
|
|
1689
1718
|
return computed.toSQL(ctx, quotedAs);
|
|
1690
1719
|
};
|
|
1691
1720
|
function simpleColumnToSQL(ctx, q, key, column, quotedAs) {
|
|
@@ -2709,12 +2738,9 @@ const _join = (query, require2, type, first, args) => {
|
|
|
2709
2738
|
if (shape) {
|
|
2710
2739
|
if (!require2)
|
|
2711
2740
|
shape = __spreadValues$h({}, shape);
|
|
2712
|
-
|
|
2741
|
+
const arg = { parsers: {} };
|
|
2713
2742
|
for (const key in shape) {
|
|
2714
|
-
|
|
2715
|
-
if (parser) {
|
|
2716
|
-
parsers[key] = parser;
|
|
2717
|
-
}
|
|
2743
|
+
addColumnParserToQuery(arg, key, shape[key]);
|
|
2718
2744
|
}
|
|
2719
2745
|
}
|
|
2720
2746
|
}
|
|
@@ -2870,19 +2896,8 @@ class ArrayColumn extends ColumnType {
|
|
|
2870
2896
|
super(schema, inputType, outputType, queryType);
|
|
2871
2897
|
this.dataType = "array";
|
|
2872
2898
|
this.operators = Operators.array;
|
|
2873
|
-
this.parseFn = Object.assign(
|
|
2874
|
-
(source) => {
|
|
2875
|
-
if (!source)
|
|
2876
|
-
return source;
|
|
2877
|
-
const entries = [];
|
|
2878
|
-
parsePostgresArray(source, entries, this.data.item.parseItem);
|
|
2879
|
-
return entries;
|
|
2880
|
-
},
|
|
2881
|
-
{
|
|
2882
|
-
hideFromCode: true
|
|
2883
|
-
}
|
|
2884
|
-
);
|
|
2885
2899
|
item.data.isNullable = true;
|
|
2900
|
+
setColumnDefaultParse(this, (input) => parse.call(this, input));
|
|
2886
2901
|
this.data.item = item instanceof ArrayColumn ? item.data.item : item;
|
|
2887
2902
|
this.data.name = item.data.name;
|
|
2888
2903
|
this.data.arrayDims = item instanceof ArrayColumn ? item.data.arrayDims + 1 : 1;
|
|
@@ -2907,6 +2922,11 @@ class ArrayColumn extends ColumnType {
|
|
|
2907
2922
|
return columnCode(this, ctx, key, code);
|
|
2908
2923
|
}
|
|
2909
2924
|
}
|
|
2925
|
+
const parse = function(source) {
|
|
2926
|
+
const entries = [];
|
|
2927
|
+
parsePostgresArray(source, entries, this.data.item.data.parseItem);
|
|
2928
|
+
return entries;
|
|
2929
|
+
};
|
|
2910
2930
|
const parsePostgresArray = (source, entries, transform) => {
|
|
2911
2931
|
let pos = 0;
|
|
2912
2932
|
if (source[0] === "[") {
|
|
@@ -3024,8 +3044,8 @@ class SmallIntColumn extends IntegerBaseColumn {
|
|
|
3024
3044
|
constructor(schema) {
|
|
3025
3045
|
super(schema);
|
|
3026
3046
|
this.dataType = "int2";
|
|
3027
|
-
this.parseItem = parseInt;
|
|
3028
3047
|
this.data.alias = "smallint";
|
|
3048
|
+
this.data.parseItem = parseInt;
|
|
3029
3049
|
}
|
|
3030
3050
|
toCode(ctx, key) {
|
|
3031
3051
|
return intToCode(this, ctx, key, "smallint");
|
|
@@ -3038,8 +3058,8 @@ class IntegerColumn extends IntegerBaseColumn {
|
|
|
3038
3058
|
constructor(schema) {
|
|
3039
3059
|
super(schema);
|
|
3040
3060
|
this.dataType = "int4";
|
|
3041
|
-
this.parseItem = parseInt;
|
|
3042
3061
|
this.data.alias = "integer";
|
|
3062
|
+
this.data.parseItem = parseInt;
|
|
3043
3063
|
}
|
|
3044
3064
|
toCode(ctx, key) {
|
|
3045
3065
|
return intToCode(this, ctx, key, "integer");
|
|
@@ -3065,8 +3085,8 @@ class RealColumn extends NumberBaseColumn {
|
|
|
3065
3085
|
constructor(schema) {
|
|
3066
3086
|
super(schema, schema.number());
|
|
3067
3087
|
this.dataType = "float4";
|
|
3068
|
-
this.parseItem = parseFloat;
|
|
3069
3088
|
this.data.alias = "real";
|
|
3089
|
+
this.data.parseItem = parseFloat;
|
|
3070
3090
|
}
|
|
3071
3091
|
toCode(ctx, key) {
|
|
3072
3092
|
return columnCode(
|
|
@@ -3091,9 +3111,9 @@ class SmallSerialColumn extends IntegerBaseColumn {
|
|
|
3091
3111
|
constructor(schema) {
|
|
3092
3112
|
super(schema);
|
|
3093
3113
|
this.dataType = "int2";
|
|
3094
|
-
this.parseItem = parseInt;
|
|
3095
3114
|
this.data.int = true;
|
|
3096
3115
|
this.data.alias = "smallSerial";
|
|
3116
|
+
this.data.parseItem = parseInt;
|
|
3097
3117
|
}
|
|
3098
3118
|
toSQL() {
|
|
3099
3119
|
return "smallserial";
|
|
@@ -3115,9 +3135,9 @@ class SerialColumn extends IntegerBaseColumn {
|
|
|
3115
3135
|
constructor(schema) {
|
|
3116
3136
|
super(schema);
|
|
3117
3137
|
this.dataType = "int4";
|
|
3118
|
-
this.parseItem = parseInt;
|
|
3119
3138
|
this.data.int = true;
|
|
3120
3139
|
this.data.alias = "serial";
|
|
3140
|
+
this.data.parseItem = parseInt;
|
|
3121
3141
|
}
|
|
3122
3142
|
toSQL() {
|
|
3123
3143
|
return "serial";
|
|
@@ -3149,29 +3169,31 @@ class BigSerialColumn extends NumberAsStringBaseColumn {
|
|
|
3149
3169
|
}
|
|
3150
3170
|
}
|
|
3151
3171
|
|
|
3152
|
-
const
|
|
3153
|
-
const parseDateToDate = (value) => value ? new Date(value) : value;
|
|
3154
|
-
parseDateToNumber.hideFromCode = parseDateToDate.hideFromCode = true;
|
|
3172
|
+
const parseDateToDate = (value) => new Date(value);
|
|
3155
3173
|
const defaultSchemaConfig = {
|
|
3174
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3156
3175
|
parse(fn) {
|
|
3157
|
-
return
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3176
|
+
return setColumnParse(this, fn);
|
|
3177
|
+
},
|
|
3178
|
+
parseNull(fn) {
|
|
3179
|
+
return setColumnParseNull(this, fn);
|
|
3161
3180
|
},
|
|
3181
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3162
3182
|
encode(fn) {
|
|
3163
|
-
return
|
|
3164
|
-
encodeFn: fn
|
|
3165
|
-
});
|
|
3183
|
+
return setColumnData(this, "encode", fn);
|
|
3166
3184
|
},
|
|
3167
3185
|
asType() {
|
|
3168
3186
|
return this;
|
|
3169
3187
|
},
|
|
3170
3188
|
dateAsNumber() {
|
|
3171
|
-
|
|
3189
|
+
const c = this.parse(Date.parse);
|
|
3190
|
+
c.data.defaultParse = Date.parse;
|
|
3191
|
+
return c;
|
|
3172
3192
|
},
|
|
3173
3193
|
dateAsDate() {
|
|
3174
|
-
|
|
3194
|
+
const c = this.parse(parseDateToDate);
|
|
3195
|
+
c.data.defaultParse = parseDateToDate;
|
|
3196
|
+
return c;
|
|
3175
3197
|
},
|
|
3176
3198
|
enum(dataType, type) {
|
|
3177
3199
|
return new EnumColumn(defaultSchemaConfig, dataType, type, void 0);
|
|
@@ -4275,9 +4297,8 @@ var __spreadValues$d = (a, b) => {
|
|
|
4275
4297
|
};
|
|
4276
4298
|
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
4277
4299
|
const addParserForRawExpression = (q, key, raw) => {
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
setParserToQuery(q.q, key, type.parseFn);
|
|
4300
|
+
if (raw.result.value)
|
|
4301
|
+
addColumnParserToQuery(q.q, key, raw.result.value);
|
|
4281
4302
|
};
|
|
4282
4303
|
const addParsersForSelectJoined = (q, arg, as = arg) => {
|
|
4283
4304
|
var _a, _b, _c, _d;
|
|
@@ -4902,7 +4923,6 @@ function queryFrom(self, arg) {
|
|
|
4902
4923
|
data.as || (data.as = "t");
|
|
4903
4924
|
} else if (Array.isArray(arg)) {
|
|
4904
4925
|
const { shape } = data;
|
|
4905
|
-
const parsers = (_c = data.parsers) != null ? _c : data.parsers = {};
|
|
4906
4926
|
for (const item of arg) {
|
|
4907
4927
|
if (typeof item === "string") {
|
|
4908
4928
|
const w = data.withShapes[item];
|
|
@@ -4910,13 +4930,15 @@ function queryFrom(self, arg) {
|
|
|
4910
4930
|
if (w.computeds)
|
|
4911
4931
|
data.computeds = __spreadValues$b(__spreadValues$b({}, data.computeds), w.computeds);
|
|
4912
4932
|
for (const key in w.shape) {
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4933
|
+
addColumnParserToQuery(
|
|
4934
|
+
self,
|
|
4935
|
+
key,
|
|
4936
|
+
w.shape[key]
|
|
4937
|
+
);
|
|
4916
4938
|
}
|
|
4917
4939
|
} else if (!isExpression(item)) {
|
|
4918
4940
|
Object.assign(shape, getShapeFromSelect(item, true));
|
|
4919
|
-
Object.assign(parsers, item.q.parsers);
|
|
4941
|
+
Object.assign((_c = data.parsers) != null ? _c : data.parsers = {}, item.q.parsers);
|
|
4920
4942
|
}
|
|
4921
4943
|
}
|
|
4922
4944
|
} else {
|
|
@@ -6280,45 +6302,46 @@ class PostgisGeographyPointColumn extends ColumnType {
|
|
|
6280
6302
|
super(schema, schema.geographyPointSchema());
|
|
6281
6303
|
this.dataType = "geography(Point)";
|
|
6282
6304
|
this.operators = Operators.any;
|
|
6305
|
+
setColumnDefaultParse(this, defaultParse);
|
|
6306
|
+
this.data.encode = this.data.defaultEncode = defaultEncode;
|
|
6283
6307
|
}
|
|
6284
6308
|
static isDefaultPoint(typmod) {
|
|
6285
6309
|
return typmodType(typmod) === "Point" && typmodSrid(typmod) === defaultSrid;
|
|
6286
6310
|
}
|
|
6287
|
-
parseFn(input) {
|
|
6288
|
-
if (!input)
|
|
6289
|
-
return null;
|
|
6290
|
-
const bytes = new Uint8Array(20);
|
|
6291
|
-
for (let i = 0; i < 40; i += 2) {
|
|
6292
|
-
bytes[i / 2] = parseInt(input.slice(10 + i, 12 + i), 16);
|
|
6293
|
-
}
|
|
6294
|
-
const view = new DataView(bytes.buffer);
|
|
6295
|
-
const srid = view.getUint32(0, true);
|
|
6296
|
-
const lon = view.getFloat64(4, true);
|
|
6297
|
-
const lat = view.getFloat64(12, true);
|
|
6298
|
-
return srid === defaultSrid ? { lon, lat } : {
|
|
6299
|
-
lon,
|
|
6300
|
-
lat,
|
|
6301
|
-
srid
|
|
6302
|
-
};
|
|
6303
|
-
}
|
|
6304
|
-
encodeFn({ srid = defaultSrid, lon, lat }) {
|
|
6305
|
-
const arr = new Uint8Array(25);
|
|
6306
|
-
const view = new DataView(arr.buffer);
|
|
6307
|
-
view.setInt8(0, 1);
|
|
6308
|
-
view.setInt8(1, 1);
|
|
6309
|
-
view.setInt8(4, 32);
|
|
6310
|
-
view.setUint32(5, srid, true);
|
|
6311
|
-
view.setFloat64(9, lon, true);
|
|
6312
|
-
view.setFloat64(17, lat, true);
|
|
6313
|
-
return uint8ArrToHex(arr);
|
|
6314
|
-
}
|
|
6315
6311
|
toCode(ctx, key) {
|
|
6316
|
-
return columnCode(this, ctx, key, `geography.point()
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6312
|
+
return columnCode(this, ctx, key, `geography.point()`);
|
|
6313
|
+
}
|
|
6314
|
+
}
|
|
6315
|
+
const defaultParse = (input) => {
|
|
6316
|
+
const bytes = new Uint8Array(20);
|
|
6317
|
+
for (let i = 0; i < 40; i += 2) {
|
|
6318
|
+
bytes[i / 2] = parseInt(input.slice(10 + i, 12 + i), 16);
|
|
6319
|
+
}
|
|
6320
|
+
const view = new DataView(bytes.buffer);
|
|
6321
|
+
const srid = view.getUint32(0, true);
|
|
6322
|
+
const lon = view.getFloat64(4, true);
|
|
6323
|
+
const lat = view.getFloat64(12, true);
|
|
6324
|
+
return srid === defaultSrid ? { lon, lat } : {
|
|
6325
|
+
lon,
|
|
6326
|
+
lat,
|
|
6327
|
+
srid
|
|
6328
|
+
};
|
|
6329
|
+
};
|
|
6330
|
+
const defaultEncode = ({
|
|
6331
|
+
srid = defaultSrid,
|
|
6332
|
+
lon,
|
|
6333
|
+
lat
|
|
6334
|
+
}) => {
|
|
6335
|
+
const arr = new Uint8Array(25);
|
|
6336
|
+
const view = new DataView(arr.buffer);
|
|
6337
|
+
view.setInt8(0, 1);
|
|
6338
|
+
view.setInt8(1, 1);
|
|
6339
|
+
view.setInt8(4, 32);
|
|
6340
|
+
view.setUint32(5, srid, true);
|
|
6341
|
+
view.setFloat64(9, lon, true);
|
|
6342
|
+
view.setFloat64(17, lat, true);
|
|
6343
|
+
return uint8ArrToHex(arr);
|
|
6344
|
+
};
|
|
6322
6345
|
const typmodGetType = (typmod) => (typmod & 252) >> 2;
|
|
6323
6346
|
const lwtypeName = (type) => [
|
|
6324
6347
|
"Unknown",
|
|
@@ -6795,10 +6818,7 @@ class FnExpression extends Expression {
|
|
|
6795
6818
|
query.q.returnsOne = true;
|
|
6796
6819
|
query.q.getColumn = value;
|
|
6797
6820
|
query.q.select = [this];
|
|
6798
|
-
|
|
6799
|
-
if (parseFn) {
|
|
6800
|
-
setParserToQuery(query.q, getValueKey, parseFn);
|
|
6801
|
-
}
|
|
6821
|
+
addColumnParserToQuery(query.q, getValueKey, value);
|
|
6802
6822
|
}
|
|
6803
6823
|
// Builds function SQL.
|
|
6804
6824
|
makeSQL(ctx, quotedAs) {
|
|
@@ -6888,18 +6908,14 @@ const isSelectingCount = (q) => {
|
|
|
6888
6908
|
const { expr } = q.q;
|
|
6889
6909
|
return expr instanceof FnExpression && expr.fn === "count" && expr.args[0] === "*";
|
|
6890
6910
|
};
|
|
6891
|
-
const int = new IntegerColumn(defaultSchemaConfig);
|
|
6892
|
-
|
|
6893
|
-
const nullableInt = new IntegerColumn(defaultSchemaConfig);
|
|
6894
|
-
nullableInt.parseItem = nullableInt.parseFn = (input) => input === null ? null : parseInt(input);
|
|
6895
|
-
const nullableFloat = new RealColumn(defaultSchemaConfig);
|
|
6896
|
-
nullableFloat.parseItem = nullableFloat.parseFn = (input) => input === null ? null : parseFloat(input);
|
|
6911
|
+
const int = new IntegerColumn(defaultSchemaConfig).parse(parseInt);
|
|
6912
|
+
const float = new RealColumn(defaultSchemaConfig).parse(parseFloat);
|
|
6897
6913
|
const stringAsNumber = new NumberAsStringBaseColumn(
|
|
6898
6914
|
defaultSchemaConfig
|
|
6899
6915
|
);
|
|
6900
6916
|
const numericResultColumn = (q, arg) => {
|
|
6901
6917
|
const type = typeof arg === "string" ? _getSelectableColumn(q, arg) : arg.result.value;
|
|
6902
|
-
return type instanceof NumberBaseColumn ?
|
|
6918
|
+
return type instanceof NumberBaseColumn ? float : stringAsNumber;
|
|
6903
6919
|
};
|
|
6904
6920
|
class AggregateMethods {
|
|
6905
6921
|
/**
|
|
@@ -7361,7 +7377,7 @@ class AggregateMethods {
|
|
|
7361
7377
|
* @param over - OVER clause config
|
|
7362
7378
|
*/
|
|
7363
7379
|
rowNumber(over) {
|
|
7364
|
-
return makeFnExpression(this,
|
|
7380
|
+
return makeFnExpression(this, int, "row_number", emptyArray, {
|
|
7365
7381
|
over
|
|
7366
7382
|
});
|
|
7367
7383
|
}
|
|
@@ -7384,7 +7400,7 @@ class AggregateMethods {
|
|
|
7384
7400
|
* @param over - OVER clause config
|
|
7385
7401
|
*/
|
|
7386
7402
|
rank(over) {
|
|
7387
|
-
return makeFnExpression(this,
|
|
7403
|
+
return makeFnExpression(this, int, "rank", emptyArray, {
|
|
7388
7404
|
over
|
|
7389
7405
|
});
|
|
7390
7406
|
}
|
|
@@ -7407,7 +7423,7 @@ class AggregateMethods {
|
|
|
7407
7423
|
* @param over - OVER clause config
|
|
7408
7424
|
*/
|
|
7409
7425
|
denseRank(over) {
|
|
7410
|
-
return makeFnExpression(this,
|
|
7426
|
+
return makeFnExpression(this, int, "dense_rank", emptyArray, {
|
|
7411
7427
|
over
|
|
7412
7428
|
});
|
|
7413
7429
|
}
|
|
@@ -7430,7 +7446,7 @@ class AggregateMethods {
|
|
|
7430
7446
|
* @param over - OVER clause config
|
|
7431
7447
|
*/
|
|
7432
7448
|
percentRank(over) {
|
|
7433
|
-
return makeFnExpression(this,
|
|
7449
|
+
return makeFnExpression(this, int, "percent_rank", emptyArray, {
|
|
7434
7450
|
over
|
|
7435
7451
|
});
|
|
7436
7452
|
}
|
|
@@ -7453,7 +7469,7 @@ class AggregateMethods {
|
|
|
7453
7469
|
* @param over - OVER clause config
|
|
7454
7470
|
*/
|
|
7455
7471
|
cumeDist(over) {
|
|
7456
|
-
return makeFnExpression(this,
|
|
7472
|
+
return makeFnExpression(this, float, "cume_dist", emptyArray, {
|
|
7457
7473
|
over
|
|
7458
7474
|
});
|
|
7459
7475
|
}
|
|
@@ -7537,7 +7553,7 @@ const processCreateItem = (q, item, rowIndex, ctx, encoders) => {
|
|
|
7537
7553
|
}
|
|
7538
7554
|
if (!ctx.columns.has(key) && (shape[key] && !shape[key].data.computed || shape === anyShape) && item[key] !== void 0) {
|
|
7539
7555
|
ctx.columns.set(key, ctx.columns.size);
|
|
7540
|
-
encoders[key] = (_c = shape[key]) == null ? void 0 : _c.
|
|
7556
|
+
encoders[key] = (_c = shape[key]) == null ? void 0 : _c.data.encode;
|
|
7541
7557
|
}
|
|
7542
7558
|
}
|
|
7543
7559
|
}
|
|
@@ -10685,7 +10701,7 @@ const _queryUpdate = (query, arg) => {
|
|
|
10685
10701
|
set[key] = new RawSQL(`(SELECT * FROM "${as}")`);
|
|
10686
10702
|
}
|
|
10687
10703
|
} else {
|
|
10688
|
-
const encode = shape[key].
|
|
10704
|
+
const encode = shape[key].data.encode;
|
|
10689
10705
|
if (encode)
|
|
10690
10706
|
set[key] = encode(value);
|
|
10691
10707
|
}
|
|
@@ -12778,9 +12794,9 @@ class Db {
|
|
|
12778
12794
|
for (const key in shape) {
|
|
12779
12795
|
const column = shape[key];
|
|
12780
12796
|
column.data.key = key;
|
|
12781
|
-
if (column.
|
|
12797
|
+
if (column._parse) {
|
|
12782
12798
|
hasParsers = true;
|
|
12783
|
-
parsers[key] = column.
|
|
12799
|
+
parsers[key] = column._parse;
|
|
12784
12800
|
}
|
|
12785
12801
|
if (column.data.name) {
|
|
12786
12802
|
prepareSelectAll = true;
|
|
@@ -12806,10 +12822,9 @@ class Db {
|
|
|
12806
12822
|
arr.push(key);
|
|
12807
12823
|
if (!column.data.runtimeDefault) {
|
|
12808
12824
|
const {
|
|
12809
|
-
data: { default: def }
|
|
12810
|
-
encodeFn
|
|
12825
|
+
data: { default: def, encode }
|
|
12811
12826
|
} = column;
|
|
12812
|
-
column.data.runtimeDefault =
|
|
12827
|
+
column.data.runtimeDefault = encode ? () => encode(def()) : def;
|
|
12813
12828
|
}
|
|
12814
12829
|
}
|
|
12815
12830
|
}
|
|
@@ -13230,5 +13245,5 @@ function copyTableData(query, arg) {
|
|
|
13230
13245
|
return q;
|
|
13231
13246
|
}
|
|
13232
13247
|
|
|
13233
|
-
export { Adapter, AfterCommitError, AggregateMethods, ArrayColumn, AsMethods, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, Clear, ColumnRefExpression, ColumnType, ComputedColumn, Create, CustomTypeColumn, DateBaseColumn, DateColumn, DateTimeBaseClass, DateTimeTzBaseClass, Db, DecimalColumn, Delete, DomainColumn, DoublePrecisionColumn, DynamicRawSQL, EnumColumn, ExpressionMethods, FnExpression, For, FromMethods, Having, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, JSONColumn, JSONTextColumn, Join, JsonMethods, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, OnConflictQueryBuilder, OnMethods, Operators, OrExpression, OrchidOrmError, OrchidOrmInternalError, PathColumn, PointColumn, PolygonColumn, PostgisGeographyPointColumn, QueryBase, QueryError, QueryGet, QueryHooks, QueryLog, QueryMethods, QueryUpsertOrCreate, RawSQL, RealColumn, RefExpression, SearchMethods, Select, SerialColumn, SmallIntColumn, SmallSerialColumn, SqlMethod, StringColumn, TextBaseColumn, TextColumn, Then, TimeColumn, TimestampColumn, TimestampTZColumn, Transaction, TransactionAdapter, TransformMethods, TsQueryColumn, TsVectorColumn, UUIDColumn, UnhandledTypeError, Union, UnknownColumn, Update, VarCharColumn, VirtualColumn, Where, WithMethods, XMLColumn, _afterCommitError, _getSelectableColumn, _initQueryBuilder, _queryAfterSaveCommit, _queryAll, _queryAs, _queryChangeCounter, _queryCreate, _queryCreateFrom, _queryCreateMany, _queryCreateManyFrom, _queryCreateManyRaw, _queryCreateRaw, _queryDefaults, _queryDelete, _queryExec, _queryFindBy, _queryFindByOptional, _queryGet, _queryGetOptional, _queryHookAfterCreate, _queryHookAfterCreateCommit, _queryHookAfterDelete, _queryHookAfterDeleteCommit, _queryHookAfterQuery, _queryHookAfterSave, _queryHookAfterUpdate, _queryHookAfterUpdateCommit, _queryHookBeforeCreate, _queryHookBeforeDelete, _queryHookBeforeQuery, _queryHookBeforeSave, _queryHookBeforeUpdate, _queryInsert, _queryInsertFrom, _queryInsertMany, _queryInsertManyFrom, _queryInsertManyRaw, _queryInsertRaw, _queryJoinOn, _queryJoinOnJsonPathEquals, _queryJoinOrOn, _queryOr, _queryOrNot, _queryResolveAlias, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUnion, _queryUpdate, _queryUpdateOrThrow, _queryUpdateRaw, _queryWhere, _queryWhereExists, _queryWhereIn, _queryWhereNot, _queryWhereNotOneOf, _queryWhereNotSql, _queryWhereOneOf, _queryWhereSql, addParserForRawExpression, addParserForSelectItem, addQueryOn, anyShape, applyComputedColumns, checkIfASimpleQuery, cloneQuery, cloneQueryBaseUnscoped, columnCheckToCode, columnCode, columnForeignKeysToCode, columnIndexesToCode, columnsShapeToCode, commitSql$1 as commitSql, constraintInnerToCode, constraintToCode, copyTableData, countSelect, createDb, defaultSchemaConfig, escapeForLog, escapeForMigration, escapeString, extendQuery, filterResult, foreignKeyArgumentToCode, getClonedQueryData, getColumnInfo, getColumnTypes, getPrimaryKeys, getQueryAs, getShapeFromSelect, getSqlText, handleResult, identityToCode, indexInnerToCode, indexToCode, instantiateColumn, isDefaultTimeStamp, isQueryReturnsAll, isSelectingCount, joinSubQuery, logParamToLogObject, makeColumnTypes, makeColumnsByType, makeFnExpression, makeRegexToFindInSql, makeSQL, parseRecord, parseTableData, parseTableDataInput, postgisTypmodToSql, primaryKeyInnerToCode, processComputedBatches, processComputedResult, processSelectArg, pushLimitSQL, pushQueryArray, pushQueryOn, pushQueryOnForOuter, pushQueryOrOn, pushQueryValue, pushTableDataCode, queryFrom, queryFromSql, queryJson, queryMethodByReturnType, queryTypeWithLimitOne, queryWrap, raw, referencesArgsToCode, resolveSubQueryCallback, rollbackSql$1 as rollbackSql, saveSearchAlias, setParserForSelectedString, setQueryObjectValue, setQueryOperators, simplifyColumnDefault, sqlFn, sqlQueryArgsToExpression, tableDataMethods, templateLiteralToSQL, testTransaction, throwIfJoinLateral, throwIfNoWhere, toSQL, toSQLCacheKey };
|
|
13248
|
+
export { Adapter, AfterCommitError, AggregateMethods, ArrayColumn, AsMethods, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, Clear, ColumnRefExpression, ColumnType, ComputedColumn, Create, CustomTypeColumn, DateBaseColumn, DateColumn, DateTimeBaseClass, DateTimeTzBaseClass, Db, DecimalColumn, Delete, DomainColumn, DoublePrecisionColumn, DynamicRawSQL, EnumColumn, ExpressionMethods, FnExpression, For, FromMethods, Having, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, JSONColumn, JSONTextColumn, Join, JsonMethods, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, OnConflictQueryBuilder, OnMethods, Operators, OrExpression, OrchidOrmError, OrchidOrmInternalError, PathColumn, PointColumn, PolygonColumn, PostgisGeographyPointColumn, QueryBase, QueryError, QueryGet, QueryHooks, QueryLog, QueryMethods, QueryUpsertOrCreate, RawSQL, RealColumn, RefExpression, SearchMethods, Select, SerialColumn, SmallIntColumn, SmallSerialColumn, SqlMethod, StringColumn, TextBaseColumn, TextColumn, Then, TimeColumn, TimestampColumn, TimestampTZColumn, Transaction, TransactionAdapter, TransformMethods, TsQueryColumn, TsVectorColumn, UUIDColumn, UnhandledTypeError, Union, UnknownColumn, Update, VarCharColumn, VirtualColumn, Where, WithMethods, XMLColumn, _afterCommitError, _getSelectableColumn, _initQueryBuilder, _queryAfterSaveCommit, _queryAll, _queryAs, _queryChangeCounter, _queryCreate, _queryCreateFrom, _queryCreateMany, _queryCreateManyFrom, _queryCreateManyRaw, _queryCreateRaw, _queryDefaults, _queryDelete, _queryExec, _queryFindBy, _queryFindByOptional, _queryGet, _queryGetOptional, _queryHookAfterCreate, _queryHookAfterCreateCommit, _queryHookAfterDelete, _queryHookAfterDeleteCommit, _queryHookAfterQuery, _queryHookAfterSave, _queryHookAfterUpdate, _queryHookAfterUpdateCommit, _queryHookBeforeCreate, _queryHookBeforeDelete, _queryHookBeforeQuery, _queryHookBeforeSave, _queryHookBeforeUpdate, _queryInsert, _queryInsertFrom, _queryInsertMany, _queryInsertManyFrom, _queryInsertManyRaw, _queryInsertRaw, _queryJoinOn, _queryJoinOnJsonPathEquals, _queryJoinOrOn, _queryOr, _queryOrNot, _queryResolveAlias, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUnion, _queryUpdate, _queryUpdateOrThrow, _queryUpdateRaw, _queryWhere, _queryWhereExists, _queryWhereIn, _queryWhereNot, _queryWhereNotOneOf, _queryWhereNotSql, _queryWhereOneOf, _queryWhereSql, addColumnParserToQuery, addParserForRawExpression, addParserForSelectItem, addQueryOn, anyShape, applyComputedColumns, checkIfASimpleQuery, cloneQuery, cloneQueryBaseUnscoped, columnCheckToCode, columnCode, columnForeignKeysToCode, columnIndexesToCode, columnsShapeToCode, commitSql$1 as commitSql, constraintInnerToCode, constraintToCode, copyTableData, countSelect, createDb, defaultSchemaConfig, escapeForLog, escapeForMigration, escapeString, extendQuery, filterResult, foreignKeyArgumentToCode, getClonedQueryData, getColumnInfo, getColumnTypes, getPrimaryKeys, getQueryAs, getShapeFromSelect, getSqlText, handleResult, identityToCode, indexInnerToCode, indexToCode, instantiateColumn, isDefaultTimeStamp, isQueryReturnsAll, isSelectingCount, joinSubQuery, logParamToLogObject, makeColumnTypes, makeColumnsByType, makeFnExpression, makeRegexToFindInSql, makeSQL, parseRecord, parseTableData, parseTableDataInput, postgisTypmodToSql, primaryKeyInnerToCode, processComputedBatches, processComputedResult, processSelectArg, pushLimitSQL, pushQueryArray, pushQueryOn, pushQueryOnForOuter, pushQueryOrOn, pushQueryValue, pushTableDataCode, queryFrom, queryFromSql, queryJson, queryMethodByReturnType, queryTypeWithLimitOne, queryWrap, raw, referencesArgsToCode, resolveSubQueryCallback, rollbackSql$1 as rollbackSql, saveSearchAlias, setColumnDefaultParse, setColumnEncode, setColumnParse, setColumnParseNull, setParserForSelectedString, setQueryObjectValue, setQueryOperators, simplifyColumnDefault, sqlFn, sqlQueryArgsToExpression, tableDataMethods, templateLiteralToSQL, testTransaction, throwIfJoinLateral, throwIfNoWhere, toSQL, toSQLCacheKey };
|
|
13234
13249
|
//# sourceMappingURL=index.mjs.map
|