pqb 0.36.15 → 0.36.16
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 +2 -2
- package/dist/index.js +33 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -2951,7 +2951,7 @@ declare abstract class LimitedTextBaseColumn<Schema extends ColumnSchemaConfig>
|
|
|
2951
2951
|
data: TextColumnData & {
|
|
2952
2952
|
maxChars?: number;
|
|
2953
2953
|
};
|
|
2954
|
-
constructor(schema: Schema, limit
|
|
2954
|
+
constructor(schema: Schema, limit?: number);
|
|
2955
2955
|
toSQL(): string;
|
|
2956
2956
|
}
|
|
2957
2957
|
declare class VarCharColumn<Schema extends ColumnSchemaConfig> extends LimitedTextBaseColumn<Schema> {
|
|
@@ -3181,7 +3181,7 @@ interface DefaultSchemaConfig extends ColumnSchemaConfig<ColumnType> {
|
|
|
3181
3181
|
doublePrecision(): DoublePrecisionColumn<DefaultSchemaConfig>;
|
|
3182
3182
|
bigSerial(): BigSerialColumn<DefaultSchemaConfig>;
|
|
3183
3183
|
money(): MoneyColumn<DefaultSchemaConfig>;
|
|
3184
|
-
varchar(limit
|
|
3184
|
+
varchar(limit?: number): VarCharColumn<DefaultSchemaConfig>;
|
|
3185
3185
|
text(): TextColumn<DefaultSchemaConfig>;
|
|
3186
3186
|
string(limit?: number): StringColumn$1<DefaultSchemaConfig>;
|
|
3187
3187
|
citext(): CitextColumn<DefaultSchemaConfig>;
|
package/dist/index.js
CHANGED
|
@@ -1270,11 +1270,17 @@ class TextBaseColumn extends ColumnType {
|
|
|
1270
1270
|
}
|
|
1271
1271
|
class LimitedTextBaseColumn extends TextBaseColumn {
|
|
1272
1272
|
constructor(schema, limit) {
|
|
1273
|
-
super(
|
|
1273
|
+
super(
|
|
1274
|
+
schema,
|
|
1275
|
+
limit !== void 0 ? schema.stringMax(limit) : schema.stringSchema()
|
|
1276
|
+
);
|
|
1274
1277
|
this.data.maxChars = limit;
|
|
1275
1278
|
}
|
|
1276
1279
|
toSQL() {
|
|
1277
|
-
return orchidCore.joinTruthy(
|
|
1280
|
+
return orchidCore.joinTruthy(
|
|
1281
|
+
this.dataType,
|
|
1282
|
+
this.data.maxChars !== void 0 && `(${this.data.maxChars})`
|
|
1283
|
+
);
|
|
1278
1284
|
}
|
|
1279
1285
|
}
|
|
1280
1286
|
class VarCharColumn extends LimitedTextBaseColumn {
|
|
@@ -2593,7 +2599,7 @@ var __spreadValues$g = (a, b) => {
|
|
|
2593
2599
|
return a;
|
|
2594
2600
|
};
|
|
2595
2601
|
var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
|
|
2596
|
-
const processJoinArgs = (joinTo, first, args, joinSubQuery) => {
|
|
2602
|
+
const processJoinArgs = (joinTo, first, args, joinSubQuery, whereExists) => {
|
|
2597
2603
|
var _a;
|
|
2598
2604
|
if (typeof first === "string") {
|
|
2599
2605
|
if (first in joinTo.relations) {
|
|
@@ -2603,7 +2609,11 @@ const processJoinArgs = (joinTo, first, args, joinSubQuery) => {
|
|
|
2603
2609
|
const r = args[0](
|
|
2604
2610
|
makeJoinQueryBuilder(j, j.q.joinedShapes, joinTo)
|
|
2605
2611
|
);
|
|
2606
|
-
return {
|
|
2612
|
+
return {
|
|
2613
|
+
j: j.merge(r),
|
|
2614
|
+
s: whereExists ? false : joinSubQuery || getIsJoinSubQuery(r),
|
|
2615
|
+
r
|
|
2616
|
+
};
|
|
2607
2617
|
}
|
|
2608
2618
|
return { j, s: joinSubQuery };
|
|
2609
2619
|
} else if (typeof args[0] !== "function") {
|
|
@@ -2635,7 +2645,11 @@ const processJoinArgs = (joinTo, first, args, joinSubQuery) => {
|
|
|
2635
2645
|
joinTo
|
|
2636
2646
|
)
|
|
2637
2647
|
);
|
|
2638
|
-
return {
|
|
2648
|
+
return {
|
|
2649
|
+
w: first,
|
|
2650
|
+
r,
|
|
2651
|
+
s: whereExists ? false : joinSubQuery || getIsJoinSubQuery(r)
|
|
2652
|
+
};
|
|
2639
2653
|
}
|
|
2640
2654
|
}
|
|
2641
2655
|
const args0 = args.length ? args[0] : orchidCore.returnArg;
|
|
@@ -5260,7 +5274,7 @@ const makeInsertSql = (ctx, q, query, quotedAs) => {
|
|
|
5260
5274
|
const column = q.shape[key];
|
|
5261
5275
|
quotedColumns[0] = `"${(column == null ? void 0 : column.data.name) || key}"`;
|
|
5262
5276
|
if (Array.isArray(values) && Array.isArray(values[0])) {
|
|
5263
|
-
values = [
|
|
5277
|
+
values = values.map(() => [void 0]);
|
|
5264
5278
|
}
|
|
5265
5279
|
}
|
|
5266
5280
|
ctx.sql.push(
|
|
@@ -7150,7 +7164,7 @@ const processCreateItem = (q, item, rowIndex, ctx, encoders) => {
|
|
|
7150
7164
|
item[key]
|
|
7151
7165
|
);
|
|
7152
7166
|
}
|
|
7153
|
-
if (!ctx.columns.has(key) && (shape[key] && !shape[key].data.computed || shape === anyShape)) {
|
|
7167
|
+
if (!ctx.columns.has(key) && (shape[key] && !shape[key].data.computed || shape === anyShape) && item[key] !== void 0) {
|
|
7154
7168
|
ctx.columns.set(key, ctx.columns.size);
|
|
7155
7169
|
encoders[key] = (_c = shape[key]) == null ? void 0 : _c.encodeFn;
|
|
7156
7170
|
}
|
|
@@ -7161,11 +7175,6 @@ const createCtx = () => ({
|
|
|
7161
7175
|
columns: /* @__PURE__ */ new Map(),
|
|
7162
7176
|
resultAll: void 0
|
|
7163
7177
|
});
|
|
7164
|
-
const mapColumnValues = (columns, encoders, data) => {
|
|
7165
|
-
return columns.map(
|
|
7166
|
-
(key) => encoders[key] && !orchidCore.isExpression(data[key]) ? encoders[key](data[key]) : data[key]
|
|
7167
|
-
);
|
|
7168
|
-
};
|
|
7169
7178
|
const handleOneData = (q, data, ctx) => {
|
|
7170
7179
|
const encoders = {};
|
|
7171
7180
|
const defaults = q.q.defaults;
|
|
@@ -7174,7 +7183,14 @@ const handleOneData = (q, data, ctx) => {
|
|
|
7174
7183
|
}
|
|
7175
7184
|
processCreateItem(q, data, 0, ctx, encoders);
|
|
7176
7185
|
const columns = Array.from(ctx.columns.keys());
|
|
7177
|
-
const values = [
|
|
7186
|
+
const values = [
|
|
7187
|
+
columns.map(
|
|
7188
|
+
(key) => (
|
|
7189
|
+
// undefined values were stripped and no need to check for them
|
|
7190
|
+
encoders[key] && !orchidCore.isExpression(data[key]) ? encoders[key](data[key]) : data[key]
|
|
7191
|
+
)
|
|
7192
|
+
)
|
|
7193
|
+
];
|
|
7178
7194
|
return { columns, values };
|
|
7179
7195
|
};
|
|
7180
7196
|
const handleManyData = (q, data, ctx) => {
|
|
@@ -7189,7 +7205,9 @@ const handleManyData = (q, data, ctx) => {
|
|
|
7189
7205
|
const values = Array(data.length);
|
|
7190
7206
|
const columns = Array.from(ctx.columns.keys());
|
|
7191
7207
|
data.forEach((item, i) => {
|
|
7192
|
-
values[i] =
|
|
7208
|
+
values[i] = columns.map(
|
|
7209
|
+
(key) => encoders[key] && item[key] !== void 0 && !orchidCore.isExpression(item[key]) ? encoders[key](item[key]) : item[key]
|
|
7210
|
+
);
|
|
7193
7211
|
});
|
|
7194
7212
|
return { columns, values };
|
|
7195
7213
|
};
|
|
@@ -9454,20 +9472,7 @@ const _queryWhereIn = (q, and, arg, values, not) => {
|
|
|
9454
9472
|
return q;
|
|
9455
9473
|
};
|
|
9456
9474
|
const existsArgs = (self, q, args) => {
|
|
9457
|
-
|
|
9458
|
-
if (typeof q === "object") {
|
|
9459
|
-
joinSubQuery = getIsJoinSubQuery(q);
|
|
9460
|
-
if (joinSubQuery) {
|
|
9461
|
-
q = q.clone();
|
|
9462
|
-
q.shape = getShapeFromSelect(
|
|
9463
|
-
q,
|
|
9464
|
-
true
|
|
9465
|
-
);
|
|
9466
|
-
}
|
|
9467
|
-
} else {
|
|
9468
|
-
joinSubQuery = false;
|
|
9469
|
-
}
|
|
9470
|
-
const joinArgs = processJoinArgs(self, q, args, joinSubQuery);
|
|
9475
|
+
const joinArgs = processJoinArgs(self, q, args, false, true);
|
|
9471
9476
|
return [
|
|
9472
9477
|
{
|
|
9473
9478
|
EXISTS: joinArgs
|