pqb 0.56.2 → 0.56.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.js +46 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -27
- package/dist/index.mjs.map +1 -1
- package/dist/postgres-js.js.map +1 -1
- package/dist/postgres-js.mjs +3 -3
- package/dist/postgres-js.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5714,7 +5714,7 @@ const addParserForSelectItem = (q, as, key, arg, columnAlias, joinQuery) => {
|
|
|
5714
5714
|
}))
|
|
5715
5715
|
);
|
|
5716
5716
|
}
|
|
5717
|
-
if (query.hookSelect || query.parsers || query.transform) {
|
|
5717
|
+
if (query.hookSelect || query.parsers || query.transform || query.returnType === "oneOrThrow" || query.returnType === "valueOrThrow" || query.returnType === "one" || query.returnType === "value") {
|
|
5718
5718
|
orchidCore.pushQueryValueImmutable(q, "batchParsers", {
|
|
5719
5719
|
path: [key],
|
|
5720
5720
|
fn: (path, queryResult) => {
|
|
@@ -5755,7 +5755,7 @@ const addParserForSelectItem = (q, as, key, arg, columnAlias, joinQuery) => {
|
|
|
5755
5755
|
if (returnType === "one") {
|
|
5756
5756
|
for (const batch of batches) {
|
|
5757
5757
|
if (batch.data) parseRecord(parsers, batch.data);
|
|
5758
|
-
else batch.data = void 0;
|
|
5758
|
+
else batch.parent[batch.key] = batch.data = void 0;
|
|
5759
5759
|
}
|
|
5760
5760
|
} else {
|
|
5761
5761
|
for (const { data } of batches) {
|
|
@@ -5765,7 +5765,8 @@ const addParserForSelectItem = (q, as, key, arg, columnAlias, joinQuery) => {
|
|
|
5765
5765
|
}
|
|
5766
5766
|
} else if (returnType === "one") {
|
|
5767
5767
|
for (const batch of batches) {
|
|
5768
|
-
if (!batch.data)
|
|
5768
|
+
if (!batch.data)
|
|
5769
|
+
batch.parent[batch.key] = batch.data = void 0;
|
|
5769
5770
|
}
|
|
5770
5771
|
} else {
|
|
5771
5772
|
for (const { data } of batches) {
|
|
@@ -5792,22 +5793,30 @@ const addParserForSelectItem = (q, as, key, arg, columnAlias, joinQuery) => {
|
|
|
5792
5793
|
}
|
|
5793
5794
|
case "value":
|
|
5794
5795
|
case "valueOrThrow": {
|
|
5796
|
+
const notNullable = !query.getColumn?.data.isNullable;
|
|
5795
5797
|
const parse = query.parsers?.[orchidCore.getValueKey];
|
|
5796
5798
|
if (parse) {
|
|
5797
5799
|
if (returnType === "value") {
|
|
5798
5800
|
for (const item of batches) {
|
|
5799
|
-
item.parent[item.key] = item.data = item.data ===
|
|
5801
|
+
item.parent[item.key] = item.data = item.data === null ? query.notFoundDefault : parse(item.data);
|
|
5800
5802
|
}
|
|
5801
5803
|
} else {
|
|
5802
5804
|
for (const item of batches) {
|
|
5803
|
-
if (item.data ===
|
|
5805
|
+
if (notNullable && item.data === null) {
|
|
5804
5806
|
throw new orchidCore.NotFoundError(arg);
|
|
5807
|
+
}
|
|
5805
5808
|
item.parent[item.key] = item.data = parse(item.data);
|
|
5806
5809
|
}
|
|
5807
5810
|
}
|
|
5808
|
-
} else if (returnType
|
|
5811
|
+
} else if (returnType === "value") {
|
|
5812
|
+
for (const item of batches) {
|
|
5813
|
+
if (item.data === null) {
|
|
5814
|
+
item.parent[item.key] = item.data = query.notFoundDefault;
|
|
5815
|
+
}
|
|
5816
|
+
}
|
|
5817
|
+
} else if (notNullable) {
|
|
5809
5818
|
for (const { data } of batches) {
|
|
5810
|
-
if (data ===
|
|
5819
|
+
if (data === null) throw new orchidCore.NotFoundError(arg);
|
|
5811
5820
|
}
|
|
5812
5821
|
}
|
|
5813
5822
|
if (hookSelect) {
|
|
@@ -7841,14 +7850,18 @@ const isSelectingCount = (q) => {
|
|
|
7841
7850
|
const { expr } = q.q;
|
|
7842
7851
|
return expr instanceof FnExpression && expr.fn === "count" && expr.args[0] === "*";
|
|
7843
7852
|
};
|
|
7844
|
-
const
|
|
7845
|
-
const
|
|
7846
|
-
const
|
|
7853
|
+
const intNullable = new IntegerColumn(defaultSchemaConfig).nullable().parse(parseInt);
|
|
7854
|
+
const floatNullable = new RealColumn(defaultSchemaConfig).nullable().parse(parseFloat);
|
|
7855
|
+
const booleanNullable = BooleanColumn.instance.nullable();
|
|
7856
|
+
const textNullable = TextColumn.instance.nullable();
|
|
7857
|
+
const jsonTextNullable = JSONTextColumn.instance.nullable();
|
|
7858
|
+
const xmlNullable = XMLColumn.instance.nullable();
|
|
7859
|
+
const stringAsNumberNullable = new NumberAsStringBaseColumn(
|
|
7847
7860
|
defaultSchemaConfig
|
|
7848
|
-
);
|
|
7861
|
+
).nullable();
|
|
7849
7862
|
const numericResultColumn = (q, arg) => {
|
|
7850
7863
|
const type = typeof arg === "string" ? _getSelectableColumn(q, arg) : arg.result.value;
|
|
7851
|
-
return type instanceof NumberBaseColumn ?
|
|
7864
|
+
return type instanceof NumberBaseColumn ? floatNullable : stringAsNumberNullable;
|
|
7852
7865
|
};
|
|
7853
7866
|
class AggregateMethods {
|
|
7854
7867
|
/**
|
|
@@ -7891,7 +7904,13 @@ class AggregateMethods {
|
|
|
7891
7904
|
* @param options - aggregation options
|
|
7892
7905
|
*/
|
|
7893
7906
|
count(arg = "*", options) {
|
|
7894
|
-
return makeFnExpression(
|
|
7907
|
+
return makeFnExpression(
|
|
7908
|
+
this,
|
|
7909
|
+
intNullable,
|
|
7910
|
+
"count",
|
|
7911
|
+
[arg],
|
|
7912
|
+
options
|
|
7913
|
+
);
|
|
7895
7914
|
}
|
|
7896
7915
|
/**
|
|
7897
7916
|
* Get the minimum value for the specified numeric column, returns number or `null` if there are no records.
|
|
@@ -8086,7 +8105,7 @@ class AggregateMethods {
|
|
|
8086
8105
|
boolAnd(arg, options) {
|
|
8087
8106
|
return makeFnExpression(
|
|
8088
8107
|
this,
|
|
8089
|
-
|
|
8108
|
+
booleanNullable,
|
|
8090
8109
|
"bool_and",
|
|
8091
8110
|
[arg],
|
|
8092
8111
|
options
|
|
@@ -8115,7 +8134,7 @@ class AggregateMethods {
|
|
|
8115
8134
|
boolOr(arg, options) {
|
|
8116
8135
|
return makeFnExpression(
|
|
8117
8136
|
this,
|
|
8118
|
-
|
|
8137
|
+
booleanNullable,
|
|
8119
8138
|
"bool_or",
|
|
8120
8139
|
[arg],
|
|
8121
8140
|
options
|
|
@@ -8127,7 +8146,7 @@ class AggregateMethods {
|
|
|
8127
8146
|
every(arg, options) {
|
|
8128
8147
|
return makeFnExpression(
|
|
8129
8148
|
this,
|
|
8130
|
-
|
|
8149
|
+
booleanNullable,
|
|
8131
8150
|
"every",
|
|
8132
8151
|
[arg],
|
|
8133
8152
|
options
|
|
@@ -8160,7 +8179,7 @@ class AggregateMethods {
|
|
|
8160
8179
|
jsonAgg(arg, options) {
|
|
8161
8180
|
return makeFnExpression(
|
|
8162
8181
|
this,
|
|
8163
|
-
|
|
8182
|
+
jsonTextNullable,
|
|
8164
8183
|
"json_agg",
|
|
8165
8184
|
[arg],
|
|
8166
8185
|
options
|
|
@@ -8172,7 +8191,7 @@ class AggregateMethods {
|
|
|
8172
8191
|
jsonbAgg(arg, options) {
|
|
8173
8192
|
return makeFnExpression(
|
|
8174
8193
|
this,
|
|
8175
|
-
|
|
8194
|
+
jsonTextNullable,
|
|
8176
8195
|
"jsonb_agg",
|
|
8177
8196
|
[arg],
|
|
8178
8197
|
options
|
|
@@ -8213,7 +8232,7 @@ class AggregateMethods {
|
|
|
8213
8232
|
jsonObjectAgg(arg, options) {
|
|
8214
8233
|
return makeFnExpression(
|
|
8215
8234
|
this,
|
|
8216
|
-
|
|
8235
|
+
jsonTextNullable,
|
|
8217
8236
|
"json_object_agg",
|
|
8218
8237
|
[{ pairs: arg }],
|
|
8219
8238
|
options
|
|
@@ -8225,7 +8244,7 @@ class AggregateMethods {
|
|
|
8225
8244
|
jsonbObjectAgg(arg, options) {
|
|
8226
8245
|
return makeFnExpression(
|
|
8227
8246
|
this,
|
|
8228
|
-
|
|
8247
|
+
jsonTextNullable,
|
|
8229
8248
|
"jsonb_object_agg",
|
|
8230
8249
|
[{ pairs: arg }],
|
|
8231
8250
|
options
|
|
@@ -8256,7 +8275,7 @@ class AggregateMethods {
|
|
|
8256
8275
|
stringAgg(arg, delimiter, options) {
|
|
8257
8276
|
return makeFnExpression(
|
|
8258
8277
|
this,
|
|
8259
|
-
|
|
8278
|
+
textNullable,
|
|
8260
8279
|
"string_agg",
|
|
8261
8280
|
[arg, { value: delimiter }],
|
|
8262
8281
|
options
|
|
@@ -8282,7 +8301,7 @@ class AggregateMethods {
|
|
|
8282
8301
|
xmlAgg(arg, options) {
|
|
8283
8302
|
return makeFnExpression(
|
|
8284
8303
|
this,
|
|
8285
|
-
|
|
8304
|
+
xmlNullable,
|
|
8286
8305
|
"xmlagg",
|
|
8287
8306
|
[arg],
|
|
8288
8307
|
options
|
|
@@ -8307,7 +8326,7 @@ class AggregateMethods {
|
|
|
8307
8326
|
* @param over - OVER clause config
|
|
8308
8327
|
*/
|
|
8309
8328
|
rowNumber(over) {
|
|
8310
|
-
return makeFnExpression(this,
|
|
8329
|
+
return makeFnExpression(this, intNullable, "row_number", orchidCore.emptyArray, {
|
|
8311
8330
|
over
|
|
8312
8331
|
});
|
|
8313
8332
|
}
|
|
@@ -8330,7 +8349,7 @@ class AggregateMethods {
|
|
|
8330
8349
|
* @param over - OVER clause config
|
|
8331
8350
|
*/
|
|
8332
8351
|
rank(over) {
|
|
8333
|
-
return makeFnExpression(this,
|
|
8352
|
+
return makeFnExpression(this, intNullable, "rank", orchidCore.emptyArray, {
|
|
8334
8353
|
over
|
|
8335
8354
|
});
|
|
8336
8355
|
}
|
|
@@ -8353,7 +8372,7 @@ class AggregateMethods {
|
|
|
8353
8372
|
* @param over - OVER clause config
|
|
8354
8373
|
*/
|
|
8355
8374
|
denseRank(over) {
|
|
8356
|
-
return makeFnExpression(this,
|
|
8375
|
+
return makeFnExpression(this, intNullable, "dense_rank", orchidCore.emptyArray, {
|
|
8357
8376
|
over
|
|
8358
8377
|
});
|
|
8359
8378
|
}
|
|
@@ -8376,7 +8395,7 @@ class AggregateMethods {
|
|
|
8376
8395
|
* @param over - OVER clause config
|
|
8377
8396
|
*/
|
|
8378
8397
|
percentRank(over) {
|
|
8379
|
-
return makeFnExpression(this,
|
|
8398
|
+
return makeFnExpression(this, intNullable, "percent_rank", orchidCore.emptyArray, {
|
|
8380
8399
|
over
|
|
8381
8400
|
});
|
|
8382
8401
|
}
|
|
@@ -8399,7 +8418,7 @@ class AggregateMethods {
|
|
|
8399
8418
|
* @param over - OVER clause config
|
|
8400
8419
|
*/
|
|
8401
8420
|
cumeDist(over) {
|
|
8402
|
-
return makeFnExpression(this,
|
|
8421
|
+
return makeFnExpression(this, floatNullable, "cume_dist", orchidCore.emptyArray, {
|
|
8403
8422
|
over
|
|
8404
8423
|
});
|
|
8405
8424
|
}
|