pqb 0.51.0 → 0.51.2
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 +59 -22
- package/dist/index.js +132 -110
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +132 -110
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -446,8 +446,7 @@ const simplifyColumnDefault = (value) => {
|
|
|
446
446
|
}
|
|
447
447
|
return;
|
|
448
448
|
};
|
|
449
|
-
const
|
|
450
|
-
const column = typeFn();
|
|
449
|
+
const assignDbDataToColumn = (column, params) => {
|
|
451
450
|
const { dateTimePrecision } = params;
|
|
452
451
|
Object.assign(column.data, {
|
|
453
452
|
...params,
|
|
@@ -1999,18 +1998,14 @@ const getFullColumnTable = (q, column, index, as) => {
|
|
|
1999
1998
|
return as && table !== as && q.q.aliases?.[table] === as ? as : table;
|
|
2000
1999
|
};
|
|
2001
2000
|
|
|
2002
|
-
|
|
2003
|
-
addColumnParserToQuery(q, as, computed.result.value);
|
|
2004
|
-
return computed.toSQL(ctx, quotedAs);
|
|
2005
|
-
};
|
|
2006
|
-
function simpleColumnToSQL(ctx, q, key, column, quotedAs) {
|
|
2001
|
+
function simpleColumnToSQL(ctx, key, column, quotedAs) {
|
|
2007
2002
|
if (!column) return `"${key}"`;
|
|
2008
2003
|
const { data } = column;
|
|
2009
|
-
return data.computed ?
|
|
2004
|
+
return data.computed ? data.computed.toSQL(ctx, quotedAs) : `${quotedAs ? `${quotedAs}.` : ""}"${data.name || key}"`;
|
|
2010
2005
|
}
|
|
2011
|
-
function simpleExistingColumnToSQL(ctx,
|
|
2006
|
+
function simpleExistingColumnToSQL(ctx, key, column, quotedAs) {
|
|
2012
2007
|
const { data } = column;
|
|
2013
|
-
return data.computed ?
|
|
2008
|
+
return data.computed ? data.computed.toSQL(ctx, quotedAs) : `${quotedAs ? `${quotedAs}.` : ""}"${data.name || key}"`;
|
|
2014
2009
|
}
|
|
2015
2010
|
const columnToSql = (ctx, data, shape, column, quotedAs, select) => {
|
|
2016
2011
|
const index = column.indexOf(".");
|
|
@@ -2028,7 +2023,7 @@ const columnToSql = (ctx, data, shape, column, quotedAs, select) => {
|
|
|
2028
2023
|
if (!select && data.joinedShapes?.[column]) {
|
|
2029
2024
|
return `"${column}".r`;
|
|
2030
2025
|
}
|
|
2031
|
-
return simpleColumnToSQL(ctx,
|
|
2026
|
+
return simpleColumnToSQL(ctx, column, shape[column], quotedAs);
|
|
2032
2027
|
};
|
|
2033
2028
|
const maybeSelectedColumnToSql = (ctx, data, column, quotedAs) => {
|
|
2034
2029
|
const index = column.indexOf(".");
|
|
@@ -2042,12 +2037,12 @@ const maybeSelectedColumnToSql = (ctx, data, column, quotedAs) => {
|
|
|
2042
2037
|
for (const s of data.select) {
|
|
2043
2038
|
if (typeof s === "object" && "selectAs" in s) {
|
|
2044
2039
|
if (column in s.selectAs) {
|
|
2045
|
-
return simpleColumnToSQL(ctx,
|
|
2040
|
+
return simpleColumnToSQL(ctx, column, data.shape[column]);
|
|
2046
2041
|
}
|
|
2047
2042
|
}
|
|
2048
2043
|
}
|
|
2049
2044
|
}
|
|
2050
|
-
return simpleColumnToSQL(ctx,
|
|
2045
|
+
return simpleColumnToSQL(ctx, column, data.shape[column], quotedAs);
|
|
2051
2046
|
}
|
|
2052
2047
|
};
|
|
2053
2048
|
const columnWithDotToSql = (ctx, data, shape, column, index, quotedAs, select) => {
|
|
@@ -2065,7 +2060,7 @@ const columnWithDotToSql = (ctx, data, shape, column, index, quotedAs, select) =
|
|
|
2065
2060
|
return `"${tableName}"."${col.data.name}"`;
|
|
2066
2061
|
}
|
|
2067
2062
|
if (col.data.computed) {
|
|
2068
|
-
return
|
|
2063
|
+
return col.data.computed.toSQL(ctx, quoted);
|
|
2069
2064
|
}
|
|
2070
2065
|
return `"${tableName}"."${key}"`;
|
|
2071
2066
|
}
|
|
@@ -2105,13 +2100,7 @@ const tableColumnToSqlWithAs = (ctx, data, column, table, key, as, quotedAs, sel
|
|
|
2105
2100
|
return `"${tableName}"."${col.data.name}" "${as}"`;
|
|
2106
2101
|
}
|
|
2107
2102
|
if (col.data.computed) {
|
|
2108
|
-
return `${
|
|
2109
|
-
ctx,
|
|
2110
|
-
data,
|
|
2111
|
-
col.data.computed,
|
|
2112
|
-
as,
|
|
2113
|
-
quoted
|
|
2114
|
-
)} "${as}"`;
|
|
2103
|
+
return `${col.data.computed.toSQL(ctx, quoted)} "${as}"`;
|
|
2115
2104
|
}
|
|
2116
2105
|
}
|
|
2117
2106
|
return `"${tableName}"."${key}"${key === as ? "" : ` "${as}"`}`;
|
|
@@ -2124,13 +2113,7 @@ const ownColumnToSqlWithAs = (ctx, data, column, as, quotedAs, select, jsonList)
|
|
|
2124
2113
|
return `${quotedAs ? `${quotedAs}.` : ""}"${col.data.name}"${col.data.name === as ? "" : ` "${as}"`}`;
|
|
2125
2114
|
}
|
|
2126
2115
|
if (col.data.computed) {
|
|
2127
|
-
return `${
|
|
2128
|
-
ctx,
|
|
2129
|
-
data,
|
|
2130
|
-
col.data.computed,
|
|
2131
|
-
as,
|
|
2132
|
-
quotedAs
|
|
2133
|
-
)} "${as}"`;
|
|
2116
|
+
return `${col.data.computed.toSQL(ctx, quotedAs)} "${as}"`;
|
|
2134
2117
|
}
|
|
2135
2118
|
}
|
|
2136
2119
|
return `${quotedAs ? `${quotedAs}.` : ""}"${column}"${column === as ? "" : ` "${as}"`}`;
|
|
@@ -2146,7 +2129,7 @@ const makeRowToJson = (table, shape, aliasName) => {
|
|
|
2146
2129
|
const list = [];
|
|
2147
2130
|
for (const key in shape) {
|
|
2148
2131
|
const column = shape[key];
|
|
2149
|
-
if (column.data.explicitSelect
|
|
2132
|
+
if (column.data.explicitSelect) {
|
|
2150
2133
|
continue;
|
|
2151
2134
|
}
|
|
2152
2135
|
if (aliasName && column.data.name || column.data.jsonCast) {
|
|
@@ -3070,17 +3053,31 @@ const applyComputedColumns = (q, fn) => {
|
|
|
3070
3053
|
q.computeBatchAtRuntime = computeBatchAtRuntime;
|
|
3071
3054
|
const computed = fn(q);
|
|
3072
3055
|
for (const key in computed) {
|
|
3073
|
-
|
|
3056
|
+
let item = computed[key];
|
|
3057
|
+
if (typeof item === "function") item = item.call(computed);
|
|
3074
3058
|
if (item instanceof ComputedColumn) {
|
|
3075
3059
|
q.q.computeds = {
|
|
3076
3060
|
...q.q.computeds,
|
|
3077
3061
|
[key]: item
|
|
3078
3062
|
};
|
|
3079
3063
|
} else {
|
|
3080
|
-
|
|
3064
|
+
let col = item.result.value;
|
|
3065
|
+
if (!col) {
|
|
3066
|
+
item.result.value = col = Object.create(
|
|
3067
|
+
UnknownColumn.instance
|
|
3068
|
+
);
|
|
3069
|
+
col.data = { ...col.data };
|
|
3070
|
+
}
|
|
3071
|
+
q.shape[key] = col;
|
|
3072
|
+
const { data } = col;
|
|
3081
3073
|
data.computed = item;
|
|
3082
3074
|
data.explicitSelect = true;
|
|
3083
3075
|
data.readonly = true;
|
|
3076
|
+
addColumnParserToQuery(
|
|
3077
|
+
q.q,
|
|
3078
|
+
key,
|
|
3079
|
+
item.result.value
|
|
3080
|
+
);
|
|
3084
3081
|
}
|
|
3085
3082
|
}
|
|
3086
3083
|
q.computeAtRuntime = q.computeBatchAtRuntime = void 0;
|
|
@@ -3370,9 +3367,13 @@ const then = async (q, adapter, trx, beforeHooks, afterHooks, afterCommitHooks,
|
|
|
3370
3367
|
let renames;
|
|
3371
3368
|
if (hookSelect) {
|
|
3372
3369
|
for (const column of hookSelect.keys()) {
|
|
3373
|
-
const as = hookSelect.get(column)
|
|
3374
|
-
if (as)
|
|
3375
|
-
|
|
3370
|
+
const { as, temp } = hookSelect.get(column);
|
|
3371
|
+
if (as) {
|
|
3372
|
+
(renames ?? (renames = {}))[column] = as;
|
|
3373
|
+
}
|
|
3374
|
+
if (temp) {
|
|
3375
|
+
(tempColumns ?? (tempColumns = /* @__PURE__ */ new Set()))?.add(temp);
|
|
3376
|
+
}
|
|
3376
3377
|
}
|
|
3377
3378
|
if (renames) {
|
|
3378
3379
|
for (const record of result) {
|
|
@@ -3439,9 +3440,11 @@ const then = async (q, adapter, trx, beforeHooks, afterHooks, afterCommitHooks,
|
|
|
3439
3440
|
}
|
|
3440
3441
|
if (hookSelect || tempReturnType !== returnType) {
|
|
3441
3442
|
if (renames) {
|
|
3442
|
-
for (const
|
|
3443
|
-
for (const
|
|
3443
|
+
for (const a in renames) {
|
|
3444
|
+
for (const record of result) {
|
|
3445
|
+
const value = record[a];
|
|
3444
3446
|
record[a] = record[renames[a]];
|
|
3447
|
+
record[renames[a]] = value;
|
|
3445
3448
|
}
|
|
3446
3449
|
}
|
|
3447
3450
|
}
|
|
@@ -3484,7 +3487,8 @@ const then = async (q, adapter, trx, beforeHooks, afterHooks, afterCommitHooks,
|
|
|
3484
3487
|
if (log && sql) {
|
|
3485
3488
|
log.onError(error, sql, logData);
|
|
3486
3489
|
}
|
|
3487
|
-
return reject
|
|
3490
|
+
if (reject) return reject(error);
|
|
3491
|
+
throw error;
|
|
3488
3492
|
}
|
|
3489
3493
|
};
|
|
3490
3494
|
const execQuery = (adapter, method, sql) => {
|
|
@@ -3907,7 +3911,7 @@ const addParsersForSelectJoined = (q, arg, as = arg) => {
|
|
|
3907
3911
|
);
|
|
3908
3912
|
}
|
|
3909
3913
|
};
|
|
3910
|
-
const addParserForSelectItem = (q, as, key, arg, joinQuery) => {
|
|
3914
|
+
const addParserForSelectItem = (q, as, key, arg, columnAlias, joinQuery) => {
|
|
3911
3915
|
if (typeof arg === "object" || typeof arg === "function") {
|
|
3912
3916
|
const { q: query } = arg;
|
|
3913
3917
|
if (query.batchParsers) {
|
|
@@ -4079,7 +4083,13 @@ const addParserForSelectItem = (q, as, key, arg, joinQuery) => {
|
|
|
4079
4083
|
}
|
|
4080
4084
|
return arg;
|
|
4081
4085
|
}
|
|
4082
|
-
return setParserForSelectedString(
|
|
4086
|
+
return setParserForSelectedString(
|
|
4087
|
+
q,
|
|
4088
|
+
arg,
|
|
4089
|
+
as,
|
|
4090
|
+
key,
|
|
4091
|
+
columnAlias
|
|
4092
|
+
);
|
|
4083
4093
|
};
|
|
4084
4094
|
const collectNestedSelectBatches = (batches, rows, path, last) => {
|
|
4085
4095
|
const stack = rows.map(
|
|
@@ -4171,78 +4181,75 @@ const processSelectArg = (q, as, arg, columnAs) => {
|
|
|
4171
4181
|
as,
|
|
4172
4182
|
key,
|
|
4173
4183
|
value,
|
|
4184
|
+
key,
|
|
4174
4185
|
joinQuery
|
|
4175
4186
|
);
|
|
4176
4187
|
}
|
|
4177
4188
|
return { selectAs };
|
|
4178
4189
|
};
|
|
4179
|
-
const setParserForSelectedString = (query, arg, as, columnAs) => {
|
|
4190
|
+
const setParserForSelectedString = (query, arg, as, columnAs, columnAlias) => {
|
|
4180
4191
|
const { q } = query;
|
|
4181
4192
|
const index = arg.indexOf(".");
|
|
4182
|
-
if (index
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
);
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
if (batchParsers) {
|
|
4205
|
-
let cloned = false;
|
|
4206
|
-
for (const bp of batchParsers) {
|
|
4207
|
-
if (bp.path[0] === column) {
|
|
4208
|
-
if (!cloned) {
|
|
4209
|
-
q.batchParsers = [...q.batchParsers || []];
|
|
4210
|
-
cloned = true;
|
|
4211
|
-
}
|
|
4212
|
-
q.batchParsers.push(bp);
|
|
4193
|
+
if (index === -1) {
|
|
4194
|
+
return selectColumn(query, q, arg, columnAs, columnAlias);
|
|
4195
|
+
}
|
|
4196
|
+
const table = getFullColumnTable(query, arg, index, as);
|
|
4197
|
+
const column = arg.slice(index + 1);
|
|
4198
|
+
if (column === "*") {
|
|
4199
|
+
addParsersForSelectJoined(query, table, columnAs);
|
|
4200
|
+
return table === as ? column : arg;
|
|
4201
|
+
}
|
|
4202
|
+
if (table === as) {
|
|
4203
|
+
return selectColumn(query, q, column, columnAs, columnAlias);
|
|
4204
|
+
}
|
|
4205
|
+
const parser = q.joinedParsers?.[table]?.[column];
|
|
4206
|
+
if (parser) setParserToQuery(q, columnAs || column, parser);
|
|
4207
|
+
const batchParsers = q.joinedBatchParsers?.[table];
|
|
4208
|
+
if (batchParsers) {
|
|
4209
|
+
let cloned = false;
|
|
4210
|
+
for (const bp of batchParsers) {
|
|
4211
|
+
if (bp.path[0] === column) {
|
|
4212
|
+
if (!cloned) {
|
|
4213
|
+
q.batchParsers = [...q.batchParsers || []];
|
|
4214
|
+
cloned = true;
|
|
4213
4215
|
}
|
|
4216
|
+
q.batchParsers.push(bp);
|
|
4214
4217
|
}
|
|
4215
4218
|
}
|
|
4216
|
-
const computeds = q.joinedComputeds?.[table];
|
|
4217
|
-
if (computeds?.[column]) {
|
|
4218
|
-
const computed = computeds[column];
|
|
4219
|
-
const map = q.hookSelect = new Map(q.hookSelect);
|
|
4220
|
-
for (const column2 of computed.deps) {
|
|
4221
|
-
map.set(column2, { select: `${table}.${column2}` });
|
|
4222
|
-
}
|
|
4223
|
-
setObjectValueImmutable(q, "selectedComputeds", column, computed);
|
|
4224
|
-
return;
|
|
4225
|
-
}
|
|
4226
|
-
return arg;
|
|
4227
|
-
} else {
|
|
4228
|
-
if (columnAs && q.parsers) {
|
|
4229
|
-
const parser = q.parsers?.[arg];
|
|
4230
|
-
if (parser) setObjectValueImmutable(q, "parsers", columnAs, parser);
|
|
4231
|
-
}
|
|
4232
|
-
return handleComputed(query, q.computeds, arg);
|
|
4233
4219
|
}
|
|
4234
|
-
|
|
4235
|
-
const handleComputed = (q, computeds, column) => {
|
|
4220
|
+
const computeds = q.joinedComputeds?.[table];
|
|
4236
4221
|
if (computeds?.[column]) {
|
|
4237
4222
|
const computed = computeds[column];
|
|
4238
|
-
const map = q.
|
|
4223
|
+
const map = q.hookSelect = new Map(q.hookSelect);
|
|
4239
4224
|
for (const column2 of computed.deps) {
|
|
4240
|
-
map.set(column2, { select: column2 });
|
|
4225
|
+
map.set(column2, { select: `${table}.${column2}` });
|
|
4241
4226
|
}
|
|
4242
|
-
q
|
|
4227
|
+
setObjectValueImmutable(q, "selectedComputeds", column, computed);
|
|
4243
4228
|
return;
|
|
4244
4229
|
}
|
|
4245
|
-
return
|
|
4230
|
+
return arg;
|
|
4231
|
+
};
|
|
4232
|
+
const selectColumn = (query, q, key, columnAs, columnAlias) => {
|
|
4233
|
+
if (columnAlias === "pluck") {
|
|
4234
|
+
throw new Error("?");
|
|
4235
|
+
}
|
|
4236
|
+
if (columnAs && q.parsers) {
|
|
4237
|
+
const parser = q.parsers[key];
|
|
4238
|
+
if (parser) setObjectValueImmutable(q, "parsers", columnAs, parser);
|
|
4239
|
+
}
|
|
4240
|
+
if (q.computeds?.[key]) {
|
|
4241
|
+
const computed = q.computeds[key];
|
|
4242
|
+
const map = query.q.hookSelect = new Map(query.q.hookSelect);
|
|
4243
|
+
for (const key2 of computed.deps) {
|
|
4244
|
+
map.set(key2, { select: key2 });
|
|
4245
|
+
}
|
|
4246
|
+
query.q.selectedComputeds = {
|
|
4247
|
+
...query.q.selectedComputeds,
|
|
4248
|
+
[columnAlias || key]: computed
|
|
4249
|
+
};
|
|
4250
|
+
return;
|
|
4251
|
+
}
|
|
4252
|
+
return key;
|
|
4246
4253
|
};
|
|
4247
4254
|
const getShapeFromSelect = (q, isSubQuery) => {
|
|
4248
4255
|
const query = q.q;
|
|
@@ -4844,6 +4851,7 @@ const selectToSql = (ctx, table, query, quotedAs, hookSelect = query.hookSelect,
|
|
|
4844
4851
|
return query.inCTE.selectNum || !select ? select ? "0, " + select : "0" : select;
|
|
4845
4852
|
}
|
|
4846
4853
|
let selected;
|
|
4854
|
+
let selectedAs;
|
|
4847
4855
|
const list = [];
|
|
4848
4856
|
if (query.select) {
|
|
4849
4857
|
for (const item of query.select) {
|
|
@@ -4852,8 +4860,10 @@ const selectToSql = (ctx, table, query, quotedAs, hookSelect = query.hookSelect,
|
|
|
4852
4860
|
if (item === "*") {
|
|
4853
4861
|
if (hookSelect) {
|
|
4854
4862
|
selected ?? (selected = {});
|
|
4863
|
+
selectedAs ?? (selectedAs = {});
|
|
4855
4864
|
for (const key in query.selectableShape) {
|
|
4856
4865
|
selected[key] = quotedAs;
|
|
4866
|
+
selectedAs[key] = key;
|
|
4857
4867
|
}
|
|
4858
4868
|
}
|
|
4859
4869
|
sql = selectAllSql(query, quotedAs, jsonList);
|
|
@@ -4864,6 +4874,7 @@ const selectToSql = (ctx, table, query, quotedAs, hookSelect = query.hookSelect,
|
|
|
4864
4874
|
const key = item.slice(index + 1);
|
|
4865
4875
|
if (hookSelect?.get(key)) {
|
|
4866
4876
|
(selected ?? (selected = {}))[key] = `"${tableName}"`;
|
|
4877
|
+
(selectedAs ?? (selectedAs = {}))[key] = key;
|
|
4867
4878
|
}
|
|
4868
4879
|
sql = tableColumnToSqlWithAs(
|
|
4869
4880
|
ctx,
|
|
@@ -4877,7 +4888,10 @@ const selectToSql = (ctx, table, query, quotedAs, hookSelect = query.hookSelect,
|
|
|
4877
4888
|
jsonList
|
|
4878
4889
|
);
|
|
4879
4890
|
} else {
|
|
4880
|
-
if (hookSelect?.get(item))
|
|
4891
|
+
if (hookSelect?.get(item)) {
|
|
4892
|
+
(selected ?? (selected = {}))[item] = quotedAs;
|
|
4893
|
+
(selectedAs ?? (selectedAs = {}))[item] = item;
|
|
4894
|
+
}
|
|
4881
4895
|
sql = ownColumnToSqlWithAs(
|
|
4882
4896
|
ctx,
|
|
4883
4897
|
table.q,
|
|
@@ -4895,7 +4909,9 @@ const selectToSql = (ctx, table, query, quotedAs, hookSelect = query.hookSelect,
|
|
|
4895
4909
|
if ("selectAs" in item) {
|
|
4896
4910
|
const obj = item.selectAs;
|
|
4897
4911
|
for (const as in obj) {
|
|
4898
|
-
if (hookSelect)
|
|
4912
|
+
if (hookSelect) {
|
|
4913
|
+
(selected ?? (selected = {}))[as] = true;
|
|
4914
|
+
}
|
|
4899
4915
|
const value = obj[as];
|
|
4900
4916
|
if (typeof value === "object") {
|
|
4901
4917
|
if (isExpression(value)) {
|
|
@@ -4911,6 +4927,9 @@ const selectToSql = (ctx, table, query, quotedAs, hookSelect = query.hookSelect,
|
|
|
4911
4927
|
}
|
|
4912
4928
|
}
|
|
4913
4929
|
} else if (value) {
|
|
4930
|
+
if (hookSelect) {
|
|
4931
|
+
(selectedAs ?? (selectedAs = {}))[value] = as;
|
|
4932
|
+
}
|
|
4914
4933
|
list.push(
|
|
4915
4934
|
columnToSqlWithAs(
|
|
4916
4935
|
ctx,
|
|
@@ -4952,7 +4971,7 @@ const selectToSql = (ctx, table, query, quotedAs, hookSelect = query.hookSelect,
|
|
|
4952
4971
|
quotedTable = quotedAs;
|
|
4953
4972
|
columnName = select;
|
|
4954
4973
|
col = query.shape[select];
|
|
4955
|
-
sql = simpleColumnToSQL(ctx,
|
|
4974
|
+
sql = simpleColumnToSQL(ctx, select, col, quotedAs);
|
|
4956
4975
|
}
|
|
4957
4976
|
} else {
|
|
4958
4977
|
columnName = column;
|
|
@@ -4967,9 +4986,17 @@ const selectToSql = (ctx, table, query, quotedAs, hookSelect = query.hookSelect,
|
|
|
4967
4986
|
let i = 2;
|
|
4968
4987
|
while (selected[name = `${column}${i}`]) i++;
|
|
4969
4988
|
item.as = name;
|
|
4989
|
+
item.temp = name;
|
|
4970
4990
|
sql += ` "${name}"`;
|
|
4971
|
-
} else if (
|
|
4972
|
-
|
|
4991
|
+
} else if (selectedAs?.[columnName]) {
|
|
4992
|
+
item.as = selectedAs[columnName];
|
|
4993
|
+
item.temp = columnName;
|
|
4994
|
+
continue;
|
|
4995
|
+
} else {
|
|
4996
|
+
if (col?.data.name || typeof select === "object") {
|
|
4997
|
+
sql += ` "${columnName}"`;
|
|
4998
|
+
}
|
|
4999
|
+
item.temp = columnName;
|
|
4973
5000
|
}
|
|
4974
5001
|
if (jsonList) jsonList[name] = col;
|
|
4975
5002
|
list.push(sql);
|
|
@@ -5834,13 +5861,7 @@ const processWhere = (ands, ctx, table, query, data, quotedAs) => {
|
|
|
5834
5861
|
let column = query.shape[key];
|
|
5835
5862
|
let quotedColumn;
|
|
5836
5863
|
if (column) {
|
|
5837
|
-
quotedColumn = simpleExistingColumnToSQL(
|
|
5838
|
-
ctx,
|
|
5839
|
-
query,
|
|
5840
|
-
key,
|
|
5841
|
-
column,
|
|
5842
|
-
quotedAs
|
|
5843
|
-
);
|
|
5864
|
+
quotedColumn = simpleExistingColumnToSQL(ctx, key, column, quotedAs);
|
|
5844
5865
|
} else if (!column) {
|
|
5845
5866
|
const index = key.indexOf(".");
|
|
5846
5867
|
if (index !== -1) {
|
|
@@ -5848,7 +5869,7 @@ const processWhere = (ands, ctx, table, query, data, quotedAs) => {
|
|
|
5848
5869
|
const quoted = `"${table2}"`;
|
|
5849
5870
|
const name = key.slice(index + 1);
|
|
5850
5871
|
column = quotedAs === quoted ? query.shape[name] : query.joinedShapes?.[table2]?.[name];
|
|
5851
|
-
quotedColumn = simpleColumnToSQL(ctx,
|
|
5872
|
+
quotedColumn = simpleColumnToSQL(ctx, name, column, quoted);
|
|
5852
5873
|
} else {
|
|
5853
5874
|
column = query.joinedShapes?.[key]?.value;
|
|
5854
5875
|
quotedColumn = `"${key}".r`;
|
|
@@ -7388,6 +7409,7 @@ class VirtualColumn extends ColumnType {
|
|
|
7388
7409
|
super(schema, inputSchema);
|
|
7389
7410
|
this.dataType = "";
|
|
7390
7411
|
this.operators = Operators.any;
|
|
7412
|
+
this.data.explicitSelect = true;
|
|
7391
7413
|
}
|
|
7392
7414
|
toCode() {
|
|
7393
7415
|
throw new Error(`toCode is not implemented for virtual column`);
|
|
@@ -7397,6 +7419,8 @@ class VirtualColumn extends ColumnType {
|
|
|
7397
7419
|
const _UnknownColumn = class _UnknownColumn extends VirtualColumn {
|
|
7398
7420
|
constructor(schema) {
|
|
7399
7421
|
super(schema, schema.unknown());
|
|
7422
|
+
this.selectable = true;
|
|
7423
|
+
this.data.explicitSelect = void 0;
|
|
7400
7424
|
}
|
|
7401
7425
|
};
|
|
7402
7426
|
_UnknownColumn.instance = new _UnknownColumn(defaultSchemaConfig);
|
|
@@ -11720,8 +11744,6 @@ class ColumnRefExpression extends Expression {
|
|
|
11720
11744
|
makeSQL(ctx, quotedAs) {
|
|
11721
11745
|
return simpleExistingColumnToSQL(
|
|
11722
11746
|
ctx,
|
|
11723
|
-
// it's for parsers for computed SQL. In the column ref case, parsers should be set when selecting the column ref.
|
|
11724
|
-
{},
|
|
11725
11747
|
this.name,
|
|
11726
11748
|
this.result.value,
|
|
11727
11749
|
quotedAs
|
|
@@ -13184,5 +13206,5 @@ function copyTableData(query, arg) {
|
|
|
13184
13206
|
return q;
|
|
13185
13207
|
}
|
|
13186
13208
|
|
|
13187
|
-
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, 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, _clone, _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, cloneQueryBaseUnscoped, columnCheckToCode, columnCode, columnExcludesToCode, columnForeignKeysToCode, columnIndexesToCode, columnsShapeToCode, commitSql$1 as commitSql, constraintInnerToCode, constraintToCode, copyTableData, countSelect, createDb, defaultSchemaConfig, escapeForLog, escapeForMigration, escapeString, excludeInnerToCode, excludeToCode, extendQuery, filterResult, foreignKeyArgumentToCode, getClonedQueryData, getColumnInfo, getColumnTypes, getFullColumnTable, getPrimaryKeys, getQueryAs, getShapeFromSelect, getSqlText, handleResult, identityToCode, indexInnerToCode, indexToCode,
|
|
13209
|
+
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, 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, _clone, _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, assignDbDataToColumn, checkIfASimpleQuery, cloneQueryBaseUnscoped, columnCheckToCode, columnCode, columnExcludesToCode, columnForeignKeysToCode, columnIndexesToCode, columnsShapeToCode, commitSql$1 as commitSql, constraintInnerToCode, constraintToCode, copyTableData, countSelect, createDb, defaultSchemaConfig, escapeForLog, escapeForMigration, escapeString, excludeInnerToCode, excludeToCode, extendQuery, filterResult, foreignKeyArgumentToCode, getClonedQueryData, getColumnInfo, getColumnTypes, getFullColumnTable, getPrimaryKeys, getQueryAs, getShapeFromSelect, getSqlText, handleResult, identityToCode, indexInnerToCode, indexToCode, isDefaultTimeStamp, isQueryReturnsAll, isSelectingCount, joinSubQuery, logParamToLogObject, makeColumnTypes, makeColumnsByType, makeFnExpression, makeRegexToFindInSql, parseRecord, parseTableData, parseTableDataInput, postgisTypmodToSql, primaryKeyInnerToCode, processComputedBatches, processComputedResult, processSelectArg, pushLimitSQL, pushQueryArrayImmutable, pushQueryOn, pushQueryOnForOuter, pushQueryOrOn, pushQueryValueImmutable, pushTableDataCode, queryFrom, queryFromSql, queryJson, queryMethodByReturnType, queryTypeWithLimitOne, queryWrap, raw, referencesArgsToCode, resolveSubQueryCallbackV2, rollbackSql$1 as rollbackSql, saveSearchAlias, setColumnDefaultParse, setColumnEncode, setColumnParse, setColumnParseNull, setParserForSelectedString, setQueryObjectValueImmutable, setQueryOperators, simplifyColumnDefault, sqlFn, sqlQueryArgsToExpression, tableDataMethods, templateLiteralToSQL, testTransaction, throwIfJoinLateral, throwIfNoWhere, toSQL };
|
|
13188
13210
|
//# sourceMappingURL=index.mjs.map
|