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.d.ts
CHANGED
|
@@ -2730,7 +2730,7 @@ declare class IntervalColumn<Schema extends ColumnSchemaConfig> extends ColumnTy
|
|
|
2730
2730
|
toSQL(): string;
|
|
2731
2731
|
}
|
|
2732
2732
|
|
|
2733
|
-
declare class EnumColumn<Schema extends ColumnTypeSchemaArg, SchemaType extends Schema['type'],
|
|
2733
|
+
declare class EnumColumn<Schema extends ColumnTypeSchemaArg, SchemaType extends Schema['type'], T extends readonly string[]> extends ColumnType<Schema, T[number], SchemaType, OperatorsAny> {
|
|
2734
2734
|
enumName: string;
|
|
2735
2735
|
options: T;
|
|
2736
2736
|
operators: OperatorsAny;
|
|
@@ -3367,7 +3367,7 @@ interface DefaultSchemaConfig extends ColumnSchemaConfig<ColumnType> {
|
|
|
3367
3367
|
};
|
|
3368
3368
|
dateAsNumber<T extends ColumnType>(this: T): ParseColumn<T, unknown, number>;
|
|
3369
3369
|
dateAsDate<T extends ColumnType>(this: T): ParseColumn<T, unknown, Date>;
|
|
3370
|
-
enum<
|
|
3370
|
+
enum<T extends readonly string[]>(dataType: string, type: T): EnumColumn<DefaultSchemaConfig, unknown, T>;
|
|
3371
3371
|
array<Item extends ArrayColumnValue>(item: Item): ArrayColumn<DefaultSchemaConfig, Item, unknown, unknown, unknown>;
|
|
3372
3372
|
json<T>(): JSONColumn<unknown extends T ? MaybeArray<string | number | boolean | object> : T, DefaultSchemaConfig>;
|
|
3373
3373
|
inputSchema(): undefined;
|
|
@@ -8569,7 +8569,7 @@ interface PostgisPoint {
|
|
|
8569
8569
|
declare class PostgisGeographyPointColumn<Schema extends ColumnSchemaConfig> extends ColumnType<Schema, PostgisPoint, ReturnType<Schema['geographyPointSchema']>, OperatorsAny> {
|
|
8570
8570
|
dataType: string;
|
|
8571
8571
|
operators: OperatorsAny;
|
|
8572
|
-
static encode: ({ srid, lon, lat
|
|
8572
|
+
static encode: ({ srid, lon, lat }: PostgisPoint) => string;
|
|
8573
8573
|
static isDefaultPoint(typmod: number): boolean;
|
|
8574
8574
|
constructor(schema: Schema);
|
|
8575
8575
|
toCode(ctx: ColumnToCodeCtx, key: string): Code;
|
package/dist/index.js
CHANGED
|
@@ -880,12 +880,6 @@ const columnCode = (type, ctx, key, code) => {
|
|
|
880
880
|
}
|
|
881
881
|
if (data.explicitSelect) orchidCore.addCode(code, ".select(false)");
|
|
882
882
|
if (data.isNullable) orchidCore.addCode(code, ".nullable()");
|
|
883
|
-
if (data.encode && data.encode !== data.defaultEncode)
|
|
884
|
-
orchidCore.addCode(code, `.encode(${data.encode.toString()})`);
|
|
885
|
-
if (data.parse && data.parse !== data.defaultParse)
|
|
886
|
-
orchidCore.addCode(code, `.parse(${data.parse.toString()})`);
|
|
887
|
-
if (type.data.parseNull)
|
|
888
|
-
orchidCore.addCode(code, `.parseNull(${type.data.parseNull.toString()})`);
|
|
889
883
|
if (data.as) orchidCore.addCode(code, `.as(${data.as.toCode(ctx, key)})`);
|
|
890
884
|
if (data.default !== void 0 && data.default !== data.defaultDefault && (!ctx.migration || typeof data.default !== "function")) {
|
|
891
885
|
orchidCore.addCode(
|
|
@@ -943,7 +937,7 @@ const addColumnParserToQuery = (q, key, column) => {
|
|
|
943
937
|
}
|
|
944
938
|
};
|
|
945
939
|
const setColumnDefaultParse = (column, parse) => {
|
|
946
|
-
column.data.parse =
|
|
940
|
+
column.data.parse = parse;
|
|
947
941
|
column._parse = (input) => input === null ? null : parse(input);
|
|
948
942
|
};
|
|
949
943
|
const setColumnParse = (column, fn, outputSchema) => {
|
|
@@ -1643,7 +1637,7 @@ class DateBaseColumn extends ColumnType {
|
|
|
1643
1637
|
this.operators = Operators.date;
|
|
1644
1638
|
this.asNumber = schema.dateAsNumber;
|
|
1645
1639
|
this.asDate = schema.dateAsDate;
|
|
1646
|
-
this.data.encode =
|
|
1640
|
+
this.data.encode = dateTimeEncode;
|
|
1647
1641
|
}
|
|
1648
1642
|
}
|
|
1649
1643
|
class DateColumn extends DateBaseColumn {
|
|
@@ -1787,13 +1781,13 @@ class BooleanColumn extends ColumnType {
|
|
|
1787
1781
|
}
|
|
1788
1782
|
const parseItem = (input) => input[0] === "t";
|
|
1789
1783
|
|
|
1790
|
-
const encode = (x) => x === null ? x : JSON.stringify(x);
|
|
1784
|
+
const encode$1 = (x) => x === null ? x : JSON.stringify(x);
|
|
1791
1785
|
class JSONColumn extends ColumnType {
|
|
1792
1786
|
constructor(schema, inputType) {
|
|
1793
1787
|
super(schema, inputType);
|
|
1794
1788
|
this.dataType = "jsonb";
|
|
1795
1789
|
this.operators = Operators.json;
|
|
1796
|
-
this.data.encode =
|
|
1790
|
+
this.data.encode = encode$1;
|
|
1797
1791
|
this.data.parseItem = JSON.parse;
|
|
1798
1792
|
}
|
|
1799
1793
|
toCode(ctx, key) {
|
|
@@ -2406,7 +2400,7 @@ class ArrayColumn extends ColumnType {
|
|
|
2406
2400
|
this.dataType = "array";
|
|
2407
2401
|
this.operators = Operators.array;
|
|
2408
2402
|
item.data.isNullable = true;
|
|
2409
|
-
setColumnDefaultParse(this, (input) => parse.call(this, input));
|
|
2403
|
+
setColumnDefaultParse(this, (input) => parse$1.call(this, input));
|
|
2410
2404
|
this.data.item = item instanceof ArrayColumn ? item.data.item : item;
|
|
2411
2405
|
this.data.name = item.data.name;
|
|
2412
2406
|
this.data.arrayDims = item instanceof ArrayColumn ? item.data.arrayDims + 1 : 1;
|
|
@@ -2431,7 +2425,7 @@ class ArrayColumn extends ColumnType {
|
|
|
2431
2425
|
return columnCode(this, ctx, key, code);
|
|
2432
2426
|
}
|
|
2433
2427
|
}
|
|
2434
|
-
const parse = function(source) {
|
|
2428
|
+
const parse$1 = function(source) {
|
|
2435
2429
|
if (typeof source !== "string") return source;
|
|
2436
2430
|
const entries = [];
|
|
2437
2431
|
parsePostgresArray(source, entries, this.data.item.data.parseItem);
|
|
@@ -2694,14 +2688,10 @@ const defaultSchemaConfig = {
|
|
|
2694
2688
|
return this;
|
|
2695
2689
|
},
|
|
2696
2690
|
dateAsNumber() {
|
|
2697
|
-
|
|
2698
|
-
c.data.defaultParse = Date.parse;
|
|
2699
|
-
return c;
|
|
2691
|
+
return this.parse(Date.parse);
|
|
2700
2692
|
},
|
|
2701
2693
|
dateAsDate() {
|
|
2702
|
-
|
|
2703
|
-
c.data.defaultParse = parseDateToDate;
|
|
2704
|
-
return c;
|
|
2694
|
+
return this.parse(parseDateToDate);
|
|
2705
2695
|
},
|
|
2706
2696
|
enum(dataType, type) {
|
|
2707
2697
|
return new EnumColumn(defaultSchemaConfig, dataType, type, void 0);
|
|
@@ -7186,11 +7176,7 @@ class DomainColumn extends CustomTypeColumn {
|
|
|
7186
7176
|
}
|
|
7187
7177
|
|
|
7188
7178
|
const defaultSrid = 4326;
|
|
7189
|
-
const
|
|
7190
|
-
srid = defaultSrid,
|
|
7191
|
-
lon,
|
|
7192
|
-
lat
|
|
7193
|
-
}) => {
|
|
7179
|
+
const encode = ({ srid = defaultSrid, lon, lat }) => {
|
|
7194
7180
|
const arr = new Uint8Array(25);
|
|
7195
7181
|
const view = new DataView(arr.buffer);
|
|
7196
7182
|
view.setInt8(0, 1);
|
|
@@ -7206,8 +7192,8 @@ class PostgisGeographyPointColumn extends ColumnType {
|
|
|
7206
7192
|
super(schema, schema.geographyPointSchema());
|
|
7207
7193
|
this.dataType = "geography(Point)";
|
|
7208
7194
|
this.operators = Operators.any;
|
|
7209
|
-
setColumnDefaultParse(this,
|
|
7210
|
-
this.data.encode =
|
|
7195
|
+
setColumnDefaultParse(this, parse);
|
|
7196
|
+
this.data.encode = encode;
|
|
7211
7197
|
}
|
|
7212
7198
|
static isDefaultPoint(typmod) {
|
|
7213
7199
|
return typmodType(typmod) === "Point" && typmodSrid(typmod) === defaultSrid;
|
|
@@ -7216,8 +7202,9 @@ class PostgisGeographyPointColumn extends ColumnType {
|
|
|
7216
7202
|
return columnCode(this, ctx, key, `geography.point()`);
|
|
7217
7203
|
}
|
|
7218
7204
|
}
|
|
7219
|
-
|
|
7220
|
-
|
|
7205
|
+
// It is used by test-factory
|
|
7206
|
+
PostgisGeographyPointColumn.encode = encode;
|
|
7207
|
+
const parse = (input) => {
|
|
7221
7208
|
const bytes = new Uint8Array(20);
|
|
7222
7209
|
for (let i = 0; i < 40; i += 2) {
|
|
7223
7210
|
bytes[i / 2] = parseInt(input.slice(10 + i, 12 + i), 16);
|