pqb 0.51.3 → 0.51.4
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 -3
- package/dist/index.js +14 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -878,12 +878,6 @@ const columnCode = (type, ctx, key, code) => {
|
|
|
878
878
|
}
|
|
879
879
|
if (data.explicitSelect) addCode(code, ".select(false)");
|
|
880
880
|
if (data.isNullable) addCode(code, ".nullable()");
|
|
881
|
-
if (data.encode && data.encode !== data.defaultEncode)
|
|
882
|
-
addCode(code, `.encode(${data.encode.toString()})`);
|
|
883
|
-
if (data.parse && data.parse !== data.defaultParse)
|
|
884
|
-
addCode(code, `.parse(${data.parse.toString()})`);
|
|
885
|
-
if (type.data.parseNull)
|
|
886
|
-
addCode(code, `.parseNull(${type.data.parseNull.toString()})`);
|
|
887
881
|
if (data.as) addCode(code, `.as(${data.as.toCode(ctx, key)})`);
|
|
888
882
|
if (data.default !== void 0 && data.default !== data.defaultDefault && (!ctx.migration || typeof data.default !== "function")) {
|
|
889
883
|
addCode(
|
|
@@ -941,7 +935,7 @@ const addColumnParserToQuery = (q, key, column) => {
|
|
|
941
935
|
}
|
|
942
936
|
};
|
|
943
937
|
const setColumnDefaultParse = (column, parse) => {
|
|
944
|
-
column.data.parse =
|
|
938
|
+
column.data.parse = parse;
|
|
945
939
|
column._parse = (input) => input === null ? null : parse(input);
|
|
946
940
|
};
|
|
947
941
|
const setColumnParse = (column, fn, outputSchema) => {
|
|
@@ -1641,7 +1635,7 @@ class DateBaseColumn extends ColumnType {
|
|
|
1641
1635
|
this.operators = Operators.date;
|
|
1642
1636
|
this.asNumber = schema.dateAsNumber;
|
|
1643
1637
|
this.asDate = schema.dateAsDate;
|
|
1644
|
-
this.data.encode =
|
|
1638
|
+
this.data.encode = dateTimeEncode;
|
|
1645
1639
|
}
|
|
1646
1640
|
}
|
|
1647
1641
|
class DateColumn extends DateBaseColumn {
|
|
@@ -1785,13 +1779,13 @@ class BooleanColumn extends ColumnType {
|
|
|
1785
1779
|
}
|
|
1786
1780
|
const parseItem = (input) => input[0] === "t";
|
|
1787
1781
|
|
|
1788
|
-
const encode = (x) => x === null ? x : JSON.stringify(x);
|
|
1782
|
+
const encode$1 = (x) => x === null ? x : JSON.stringify(x);
|
|
1789
1783
|
class JSONColumn extends ColumnType {
|
|
1790
1784
|
constructor(schema, inputType) {
|
|
1791
1785
|
super(schema, inputType);
|
|
1792
1786
|
this.dataType = "jsonb";
|
|
1793
1787
|
this.operators = Operators.json;
|
|
1794
|
-
this.data.encode =
|
|
1788
|
+
this.data.encode = encode$1;
|
|
1795
1789
|
this.data.parseItem = JSON.parse;
|
|
1796
1790
|
}
|
|
1797
1791
|
toCode(ctx, key) {
|
|
@@ -2404,7 +2398,7 @@ class ArrayColumn extends ColumnType {
|
|
|
2404
2398
|
this.dataType = "array";
|
|
2405
2399
|
this.operators = Operators.array;
|
|
2406
2400
|
item.data.isNullable = true;
|
|
2407
|
-
setColumnDefaultParse(this, (input) => parse.call(this, input));
|
|
2401
|
+
setColumnDefaultParse(this, (input) => parse$1.call(this, input));
|
|
2408
2402
|
this.data.item = item instanceof ArrayColumn ? item.data.item : item;
|
|
2409
2403
|
this.data.name = item.data.name;
|
|
2410
2404
|
this.data.arrayDims = item instanceof ArrayColumn ? item.data.arrayDims + 1 : 1;
|
|
@@ -2429,7 +2423,7 @@ class ArrayColumn extends ColumnType {
|
|
|
2429
2423
|
return columnCode(this, ctx, key, code);
|
|
2430
2424
|
}
|
|
2431
2425
|
}
|
|
2432
|
-
const parse = function(source) {
|
|
2426
|
+
const parse$1 = function(source) {
|
|
2433
2427
|
if (typeof source !== "string") return source;
|
|
2434
2428
|
const entries = [];
|
|
2435
2429
|
parsePostgresArray(source, entries, this.data.item.data.parseItem);
|
|
@@ -2692,14 +2686,10 @@ const defaultSchemaConfig = {
|
|
|
2692
2686
|
return this;
|
|
2693
2687
|
},
|
|
2694
2688
|
dateAsNumber() {
|
|
2695
|
-
|
|
2696
|
-
c.data.defaultParse = Date.parse;
|
|
2697
|
-
return c;
|
|
2689
|
+
return this.parse(Date.parse);
|
|
2698
2690
|
},
|
|
2699
2691
|
dateAsDate() {
|
|
2700
|
-
|
|
2701
|
-
c.data.defaultParse = parseDateToDate;
|
|
2702
|
-
return c;
|
|
2692
|
+
return this.parse(parseDateToDate);
|
|
2703
2693
|
},
|
|
2704
2694
|
enum(dataType, type) {
|
|
2705
2695
|
return new EnumColumn(defaultSchemaConfig, dataType, type, void 0);
|
|
@@ -7184,11 +7174,7 @@ class DomainColumn extends CustomTypeColumn {
|
|
|
7184
7174
|
}
|
|
7185
7175
|
|
|
7186
7176
|
const defaultSrid = 4326;
|
|
7187
|
-
const
|
|
7188
|
-
srid = defaultSrid,
|
|
7189
|
-
lon,
|
|
7190
|
-
lat
|
|
7191
|
-
}) => {
|
|
7177
|
+
const encode = ({ srid = defaultSrid, lon, lat }) => {
|
|
7192
7178
|
const arr = new Uint8Array(25);
|
|
7193
7179
|
const view = new DataView(arr.buffer);
|
|
7194
7180
|
view.setInt8(0, 1);
|
|
@@ -7204,8 +7190,8 @@ class PostgisGeographyPointColumn extends ColumnType {
|
|
|
7204
7190
|
super(schema, schema.geographyPointSchema());
|
|
7205
7191
|
this.dataType = "geography(Point)";
|
|
7206
7192
|
this.operators = Operators.any;
|
|
7207
|
-
setColumnDefaultParse(this,
|
|
7208
|
-
this.data.encode =
|
|
7193
|
+
setColumnDefaultParse(this, parse);
|
|
7194
|
+
this.data.encode = encode;
|
|
7209
7195
|
}
|
|
7210
7196
|
static isDefaultPoint(typmod) {
|
|
7211
7197
|
return typmodType(typmod) === "Point" && typmodSrid(typmod) === defaultSrid;
|
|
@@ -7214,8 +7200,9 @@ class PostgisGeographyPointColumn extends ColumnType {
|
|
|
7214
7200
|
return columnCode(this, ctx, key, `geography.point()`);
|
|
7215
7201
|
}
|
|
7216
7202
|
}
|
|
7217
|
-
|
|
7218
|
-
|
|
7203
|
+
// It is used by test-factory
|
|
7204
|
+
PostgisGeographyPointColumn.encode = encode;
|
|
7205
|
+
const parse = (input) => {
|
|
7219
7206
|
const bytes = new Uint8Array(20);
|
|
7220
7207
|
for (let i = 0; i < 40; i += 2) {
|
|
7221
7208
|
bytes[i / 2] = parseInt(input.slice(10 + i, 12 + i), 16);
|