pqb 0.68.0 → 0.68.1
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 +5 -1
- package/dist/index.js +77 -128
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -128
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +5 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1842,6 +1842,8 @@ const quoteLikeValue = (arg, ctx, quotedAs, jsonArray) => {
|
|
|
1842
1842
|
const base = {
|
|
1843
1843
|
equals: make((key, value, ctx, quotedAs) => value === null ? `${key} IS NULL` : `${key} = ${quoteValue(value, ctx, quotedAs)}`),
|
|
1844
1844
|
not: make((key, value, ctx, quotedAs) => value === null ? `${key} IS NOT NULL` : `${key} <> ${quoteValue(value, ctx, quotedAs)}`),
|
|
1845
|
+
isDistinctFrom: make((key, value, ctx, quotedAs) => `${key} IS DISTINCT FROM ${quoteValue(value, ctx, quotedAs)}`),
|
|
1846
|
+
isNotDistinctFrom: make((key, value, ctx, quotedAs) => `${key} IS NOT DISTINCT FROM ${quoteValue(value, ctx, quotedAs)}`),
|
|
1845
1847
|
in: make((key, value, ctx, quotedAs) => Array.isArray(value) && !value.length ? "false" : `${key} IN ${quoteValue(value, ctx, quotedAs, true)}`),
|
|
1846
1848
|
notIn: make((key, value, ctx, quotedAs) => Array.isArray(value) && !value.length ? "true" : `NOT ${key} IN ${quoteValue(value, ctx, quotedAs, true)}`)
|
|
1847
1849
|
};
|
|
@@ -1902,6 +1904,8 @@ const Operators = {
|
|
|
1902
1904
|
...ord,
|
|
1903
1905
|
equals: make((key, value, ctx, quotedAs) => value === null ? `nullif(${key}, 'null'::jsonb) IS NULL` : `${key} = ${quoteJsonValue(value, ctx, quotedAs)}`),
|
|
1904
1906
|
not: make((key, value, ctx, quotedAs) => value === null ? `nullif(${key}, 'null'::jsonb) IS NOT NULL` : `${key} != ${quoteJsonValue(value, ctx, quotedAs)}`),
|
|
1907
|
+
isDistinctFrom: make((key, value, ctx, quotedAs) => `${key} IS DISTINCT FROM ${quoteJsonValue(value, ctx, quotedAs)}`),
|
|
1908
|
+
isNotDistinctFrom: make((key, value, ctx, quotedAs) => `${key} IS NOT DISTINCT FROM ${quoteJsonValue(value, ctx, quotedAs)}`),
|
|
1905
1909
|
in: make((key, value, ctx, quotedAs) => Array.isArray(value) && !value.length ? "false" : `${key} IN ${quoteJsonValue(value, ctx, quotedAs, true)}`),
|
|
1906
1910
|
notIn: make((key, value, ctx, quotedAs) => Array.isArray(value) && !value.length ? "true" : `NOT ${key} IN ${quoteJsonValue(value, ctx, quotedAs, true)}`),
|
|
1907
1911
|
jsonPathQueryFirst: Object.assign(function(path, options) {
|
|
@@ -6517,130 +6521,75 @@ const resolveSubQueryCallback = (q, cb) => {
|
|
|
6517
6521
|
_setSubQueryAliases(arg);
|
|
6518
6522
|
return cb(arg);
|
|
6519
6523
|
};
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
const { data } = column;
|
|
6530
|
-
return data.computed ? `(${data.computed.toSQL(ctx, quotedAs)})` : `${quotedAs ? `${quotedAs}.` : ""}"${data.name || key}"`;
|
|
6531
|
-
}
|
|
6532
|
-
const columnToSql = (ctx, data, shape, column, quotedAs, select) => {
|
|
6533
|
-
let index = column.indexOf(".");
|
|
6534
|
-
if (index === -1) {
|
|
6535
|
-
const joinAs = data.valuesJoinedAs?.[column];
|
|
6536
|
-
if (joinAs) {
|
|
6537
|
-
column = joinAs + "." + column;
|
|
6538
|
-
index = joinAs.length;
|
|
6539
|
-
}
|
|
6540
|
-
}
|
|
6541
|
-
if (index !== -1) return columnWithDotToSql(ctx, data, shape, column, index, quotedAs, select);
|
|
6542
|
-
return simpleColumnToSQL(ctx, column, shape[column], quotedAs);
|
|
6543
|
-
};
|
|
6544
|
-
const selectedColumnToSql = (ctx, data, shape, column, quotedAs) => {
|
|
6545
|
-
const index = column.indexOf(".");
|
|
6546
|
-
return index !== -1 ? selectedColumnWithDotToSql(ctx, data, shape, column, index, quotedAs) : selectedSimpleColumnToSql(ctx, column, shape[column], quotedAs);
|
|
6547
|
-
};
|
|
6548
|
-
const selectedSimpleColumnToSql = (ctx, key, column, quotedAs) => {
|
|
6549
|
-
if (!column) return `"${key}"`;
|
|
6550
|
-
const { data } = column;
|
|
6551
|
-
return data.selectSql ? `(${data.selectSql.toSQL(ctx, quotedAs)})` : `${quotedAs ? `${quotedAs}.` : ""}"${data.name || key}"`;
|
|
6552
|
-
};
|
|
6553
|
-
/**
|
|
6554
|
-
* in a case when ordering or grouping by a column which was selected as expression:
|
|
6555
|
-
* ```ts
|
|
6556
|
-
* table.select({ x: (q) => q.sum('x') }).group('x').order('x')
|
|
6557
|
-
* ```
|
|
6558
|
-
* the column must not be prefixed with a table name.
|
|
6559
|
-
*/
|
|
6560
|
-
const maybeSelectedColumnToSql = (ctx, data, column, quotedAs) => {
|
|
6561
|
-
const index = column.indexOf(".");
|
|
6562
|
-
if (index !== -1) return columnWithDotToSql(ctx, data, data.shape, column, index, quotedAs);
|
|
6563
|
-
else {
|
|
6564
|
-
if (data.joinedShapes?.[column]) return `"${column}"."${column}"`;
|
|
6565
|
-
if (data.select) {
|
|
6566
|
-
for (const s of data.select) if (typeof s === "object" && "selectAs" in s) {
|
|
6567
|
-
if (column in s.selectAs) return simpleColumnToSQL(ctx, column, data.shape[column]);
|
|
6524
|
+
function simpleColumnToSQL(ctx, queryData, shape, key, column, quotedAs, select, as, jsonList, useSelectList, skipSelectSql) {
|
|
6525
|
+
let sql;
|
|
6526
|
+
let dontAlias;
|
|
6527
|
+
if (useSelectList && queryData.select) {
|
|
6528
|
+
for (const s of queryData.select) if (typeof s === "object" && "selectAs" in s) {
|
|
6529
|
+
if (key in s.selectAs) {
|
|
6530
|
+
dontAlias = true;
|
|
6531
|
+
sql = simpleColumnToSQL(ctx, queryData, shape, key, shape[key]);
|
|
6532
|
+
break;
|
|
6568
6533
|
}
|
|
6569
6534
|
}
|
|
6570
|
-
return simpleColumnToSQL(ctx, column, data.shape[column], quotedAs);
|
|
6571
|
-
}
|
|
6572
|
-
};
|
|
6573
|
-
const columnWithDotToSql = (ctx, data, shape, column, index, quotedAs, select) => {
|
|
6574
|
-
const table = column.slice(0, index);
|
|
6575
|
-
const key = column.slice(index + 1);
|
|
6576
|
-
if (key === "*") {
|
|
6577
|
-
const shape = data.joinedShapes?.[table];
|
|
6578
|
-
return shape ? select ? makeRowToJson(ctx, table, shape, true) : `"${table}".*` : column;
|
|
6579
|
-
}
|
|
6580
|
-
const tableName = _getQueryAliasOrName(data, table);
|
|
6581
|
-
const quoted = `"${table}"`;
|
|
6582
|
-
const col = quoted === quotedAs ? shape[key] : data.joinedShapes?.[tableName]?.[key];
|
|
6583
|
-
if (col) {
|
|
6584
|
-
if (col.data.name) return `"${tableName}"."${col.data.name}"`;
|
|
6585
|
-
if (col.data.computed) return `(${col.data.computed.toSQL(ctx, quoted)})`;
|
|
6586
|
-
return `"${tableName}"."${key}"`;
|
|
6587
6535
|
}
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
if (col.data.selectSql) return `(${col.data.selectSql.toSQL(ctx, quoted)})`;
|
|
6602
|
-
if (col.data.name) return `"${tableName}"."${col.data.name}"`;
|
|
6536
|
+
if (!sql) if (!column) {
|
|
6537
|
+
dontAlias = key === as;
|
|
6538
|
+
sql = `${quotedAs ? `${quotedAs}.` : ""}"${key}"`;
|
|
6539
|
+
} else {
|
|
6540
|
+
if (jsonList && as) jsonList[as] = column && getSelectedColumnData(column);
|
|
6541
|
+
const { data } = column;
|
|
6542
|
+
if (select && data.selectSql && !skipSelectSql) sql = `(${data.selectSql.toSQL(ctx, quotedAs)})`;
|
|
6543
|
+
else if (data.computed) sql = `(${data.computed.toSQL(ctx, quotedAs)})`;
|
|
6544
|
+
else {
|
|
6545
|
+
const name = data.name || key;
|
|
6546
|
+
dontAlias = name === as;
|
|
6547
|
+
sql = `${quotedAs ? `${quotedAs}.` : ""}"${name}"`;
|
|
6548
|
+
}
|
|
6603
6549
|
}
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
const tableColumnToSqlWithAs = (ctx, data, column, table, key, as, quotedAs, select, jsonList) => {
|
|
6550
|
+
if (as && !dontAlias) sql = `${sql} "${as}"`;
|
|
6551
|
+
return sql;
|
|
6552
|
+
}
|
|
6553
|
+
const tableColumnToSql = (ctx, data, shape, table, key, quotedAs, select, as, jsonList) => {
|
|
6554
|
+
let sql;
|
|
6555
|
+
let dontAlias;
|
|
6611
6556
|
if (key === "*") {
|
|
6612
|
-
if (jsonList) jsonList[as] = void 0;
|
|
6557
|
+
if (jsonList && as) jsonList[as] = void 0;
|
|
6613
6558
|
const shape = data.joinedShapes?.[table];
|
|
6614
|
-
if (shape) {
|
|
6615
|
-
|
|
6616
|
-
|
|
6559
|
+
if (shape) sql = select ? makeRowToJson(ctx, table, shape, true) : `"${table}".*`;
|
|
6560
|
+
else {
|
|
6561
|
+
sql = `"${table}"."${key}"`;
|
|
6562
|
+
dontAlias = true;
|
|
6563
|
+
}
|
|
6564
|
+
} else {
|
|
6565
|
+
const tableName = _getQueryAliasOrName(data, table);
|
|
6566
|
+
const quoted = `"${table}"`;
|
|
6567
|
+
const col = quoted === quotedAs ? shape[key] : data.joinedShapes?.[tableName]?.[key];
|
|
6568
|
+
if (jsonList && as) jsonList[as] = col && getSelectedColumnData(col);
|
|
6569
|
+
if (col?.data.selectSql) sql = `(${col.data.selectSql.toSQL(ctx, quoted)})`;
|
|
6570
|
+
else if (col?.data.name) sql = `"${tableName}"."${col.data.name}"`;
|
|
6571
|
+
else if (col?.data.computed) sql = `(${col.data.computed.toSQL(ctx, quoted)})`;
|
|
6572
|
+
else {
|
|
6573
|
+
sql = `"${tableName}"."${key}"`;
|
|
6574
|
+
dontAlias = key === as;
|
|
6617
6575
|
}
|
|
6618
|
-
return column;
|
|
6619
|
-
}
|
|
6620
|
-
const tableName = _getQueryAliasOrName(data, table);
|
|
6621
|
-
const quoted = `"${table}"`;
|
|
6622
|
-
const col = quoted === quotedAs ? data.shape[key] : data.joinedShapes?.[tableName][key];
|
|
6623
|
-
if (jsonList) jsonList[as] = col && getSelectedColumnData(col);
|
|
6624
|
-
if (col) {
|
|
6625
|
-
if (col.data.selectSql) return `(${col.data.selectSql.toSQL(ctx, quoted)}) "${as}"`;
|
|
6626
|
-
if (col.data.name && col.data.name !== key) return `"${tableName}"."${col.data.name}" "${as}"`;
|
|
6627
6576
|
}
|
|
6628
|
-
|
|
6577
|
+
if (as && !dontAlias) sql = `${sql} "${as}"`;
|
|
6578
|
+
return sql;
|
|
6629
6579
|
};
|
|
6630
|
-
const
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
if (col.data.selectSql) return `(${col.data.selectSql.toSQL(ctx, quotedAs)}) "${as}"`;
|
|
6639
|
-
if (col.data.name && col.data.name !== column) return `${quotedAs ? `${quotedAs}.` : ""}"${col.data.name}"${col.data.name === as ? "" : ` "${as}"`}`;
|
|
6580
|
+
const columnToSql = (ctx, data, shape, column, quotedAs, select, as, jsonList, useSelectList) => {
|
|
6581
|
+
let index = column.indexOf(".");
|
|
6582
|
+
if (index === -1 && !select) {
|
|
6583
|
+
const joinAs = data.valuesJoinedAs?.[column];
|
|
6584
|
+
if (joinAs) {
|
|
6585
|
+
column = joinAs + "." + column;
|
|
6586
|
+
index = joinAs.length;
|
|
6587
|
+
}
|
|
6640
6588
|
}
|
|
6641
|
-
return
|
|
6589
|
+
if (index !== -1) return tableColumnToSql(ctx, data, shape, column.slice(0, index), column.slice(index + 1), quotedAs, select, as, jsonList);
|
|
6590
|
+
return simpleColumnToSQL(ctx, data, shape, column, shape[column], quotedAs, select, as, jsonList, useSelectList);
|
|
6642
6591
|
};
|
|
6643
|
-
const rawOrColumnToSql = (ctx, data, expr, quotedAs,
|
|
6592
|
+
const rawOrColumnToSql = (ctx, data, shape, expr, quotedAs, select) => {
|
|
6644
6593
|
return typeof expr === "string" ? columnToSql(ctx, data, shape, expr, quotedAs, select) : expr.toSQL(ctx, quotedAs);
|
|
6645
6594
|
};
|
|
6646
6595
|
const processJoinItem = (ctx, table, query, args, quotedAs) => {
|
|
@@ -6750,7 +6699,7 @@ const getConditionsFor3Or4LengthItem = (ctx, query, target, quotedAs, args, join
|
|
|
6750
6699
|
const [leftColumn, opOrRightColumn, maybeRightColumn] = args;
|
|
6751
6700
|
const op = maybeRightColumn ? opOrRightColumn : "=";
|
|
6752
6701
|
const rightColumn = maybeRightColumn ? maybeRightColumn : opOrRightColumn;
|
|
6753
|
-
return `${rawOrColumnToSql(ctx, query, leftColumn, target
|
|
6702
|
+
return `${rawOrColumnToSql(ctx, query, joinShape, leftColumn, target)} ${op} ${rawOrColumnToSql(ctx, query, query.shape, rightColumn, quotedAs)}`;
|
|
6754
6703
|
};
|
|
6755
6704
|
const getObjectOrRawConditions = (ctx, query, data, quotedAs, joinAs, joinShape) => {
|
|
6756
6705
|
if (data === true) return "true";
|
|
@@ -6760,7 +6709,7 @@ const getObjectOrRawConditions = (ctx, query, data, quotedAs, joinAs, joinShape)
|
|
|
6760
6709
|
const shape = query.shape;
|
|
6761
6710
|
for (const key in data) {
|
|
6762
6711
|
const value = data[key];
|
|
6763
|
-
pairs.push(`${columnToSql(ctx, query, joinShape, key, joinAs)} = ${rawOrColumnToSql(ctx, query, value, quotedAs
|
|
6712
|
+
pairs.push(`${columnToSql(ctx, query, joinShape, key, joinAs)} = ${rawOrColumnToSql(ctx, query, shape, value, quotedAs)}`);
|
|
6764
6713
|
}
|
|
6765
6714
|
return pairs.join(", ");
|
|
6766
6715
|
}
|
|
@@ -6792,7 +6741,7 @@ var SelectItemExpression = class extends Expression {
|
|
|
6792
6741
|
}
|
|
6793
6742
|
makeSQL(ctx, quotedAs) {
|
|
6794
6743
|
const q = this.q;
|
|
6795
|
-
return typeof this.item === "string" ? this.item === "*" ? selectAllSql(q, quotedAs, void 0, ctx).join(", ") :
|
|
6744
|
+
return typeof this.item === "string" ? this.item === "*" ? selectAllSql(q, quotedAs, void 0, ctx).join(", ") : columnToSql(ctx, q, q.shape, this.item, quotedAs, true) : this.item.toSQL(ctx, quotedAs);
|
|
6796
6745
|
}
|
|
6797
6746
|
};
|
|
6798
6747
|
const _getSelectableColumn = (q, arg) => {
|
|
@@ -7085,13 +7034,13 @@ const selectToSqlList = (ctx, table, query, quotedAs, hookSelect = query.hookSel
|
|
|
7085
7034
|
(selected ??= {})[key] = `"${tableName}"`;
|
|
7086
7035
|
(selectedAs ??= {})[key] = key;
|
|
7087
7036
|
}
|
|
7088
|
-
sql =
|
|
7037
|
+
sql = tableColumnToSql(ctx, table.q, table.q.shape, tableName, key, quotedAs, true, key === "*" ? tableName : key, jsonList);
|
|
7089
7038
|
} else {
|
|
7090
7039
|
if (hookSelect?.get(item)) {
|
|
7091
7040
|
(selected ??= {})[item] = quotedAs;
|
|
7092
7041
|
(selectedAs ??= {})[item] = item;
|
|
7093
7042
|
}
|
|
7094
|
-
sql =
|
|
7043
|
+
sql = simpleColumnToSQL(ctx, table.q, table.q.shape, item, table.q.shape[item], quotedAs, true, item, jsonList);
|
|
7095
7044
|
}
|
|
7096
7045
|
}
|
|
7097
7046
|
list.push(sql);
|
|
@@ -7113,7 +7062,7 @@ const selectToSqlList = (ctx, table, query, quotedAs, hookSelect = query.hookSel
|
|
|
7113
7062
|
}
|
|
7114
7063
|
else if (value) {
|
|
7115
7064
|
if (hookSelect) (selectedAs ??= {})[value] = as;
|
|
7116
|
-
list.push(
|
|
7065
|
+
list.push(columnToSql(ctx, table.q, table.q.shape, value, quotedAs, true, as, jsonList));
|
|
7117
7066
|
aliases?.push(as);
|
|
7118
7067
|
}
|
|
7119
7068
|
}
|
|
@@ -7149,12 +7098,12 @@ const selectToSqlList = (ctx, table, query, quotedAs, hookSelect = query.hookSel
|
|
|
7149
7098
|
quotedTable = `"${tableName}"`;
|
|
7150
7099
|
columnName = select.slice(index + 1);
|
|
7151
7100
|
col = table.q.joinedShapes?.[tableName]?.[columnName];
|
|
7152
|
-
sql =
|
|
7101
|
+
sql = columnToSql(ctx, table.q, table.q.shape, select, void 0, true);
|
|
7153
7102
|
} else {
|
|
7154
7103
|
quotedTable = quotedAs;
|
|
7155
7104
|
columnName = select;
|
|
7156
7105
|
col = query.shape[select];
|
|
7157
|
-
sql =
|
|
7106
|
+
sql = columnToSql(ctx, table.q, query.shape, select, quotedAs, true);
|
|
7158
7107
|
}
|
|
7159
7108
|
} else {
|
|
7160
7109
|
columnName = column;
|
|
@@ -7428,7 +7377,7 @@ const whereExprOrQuery = (ctx, ands, query, key, value, quotedAs) => {
|
|
|
7428
7377
|
else {
|
|
7429
7378
|
let column = query.shape[key];
|
|
7430
7379
|
let quotedColumn;
|
|
7431
|
-
if (column) quotedColumn =
|
|
7380
|
+
if (column) quotedColumn = simpleColumnToSQL(ctx, query, query.shape, key, column, quotedAs);
|
|
7432
7381
|
else if (!column) {
|
|
7433
7382
|
const index = key.indexOf(".");
|
|
7434
7383
|
if (index !== -1) {
|
|
@@ -7436,7 +7385,7 @@ const whereExprOrQuery = (ctx, ands, query, key, value, quotedAs) => {
|
|
|
7436
7385
|
const quoted = `"${table}"`;
|
|
7437
7386
|
const name = key.slice(index + 1);
|
|
7438
7387
|
column = quotedAs === quoted ? query.shape[name] : query.joinedShapes?.[table]?.[name];
|
|
7439
|
-
quotedColumn = simpleColumnToSQL(ctx, name, column, quoted);
|
|
7388
|
+
quotedColumn = simpleColumnToSQL(ctx, query, query.shape, name, column, quoted);
|
|
7440
7389
|
} else {
|
|
7441
7390
|
column = query.joinedShapes?.[key]?.value;
|
|
7442
7391
|
quotedColumn = `"${key}"."${key}"`;
|
|
@@ -7996,13 +7945,13 @@ const addOrder = (ctx, data, column, quotedAs, dir) => {
|
|
|
7996
7945
|
const order = dir || (!search.order || search.order === true ? emptyObject : search.order);
|
|
7997
7946
|
return `${order.coverDensity ? "ts_rank_cd" : "ts_rank"}(${order.weights ? `${addValue(ctx.values, `{${order.weights}}`)}, ` : ""}${search.vectorSQL}, "${column}"${order.normalization !== void 0 ? `, ${addValue(ctx.values, order.normalization)}` : ""}) ${order.dir || "DESC"}`;
|
|
7998
7947
|
}
|
|
7999
|
-
return `${
|
|
7948
|
+
return `${columnToSql(ctx, data, data.shape, column, quotedAs, void 0, void 0, void 0, true)} ${dir || "ASC"}`;
|
|
8000
7949
|
};
|
|
8001
7950
|
const windowToSql = (ctx, data, window, quotedAs) => {
|
|
8002
7951
|
if (typeof window === "string") return `"${window}"`;
|
|
8003
7952
|
if (isExpression(window)) return `(${window.toSQL(ctx, quotedAs)})`;
|
|
8004
7953
|
const sql = [];
|
|
8005
|
-
if (window.partitionBy) sql.push(`PARTITION BY ${Array.isArray(window.partitionBy) ? window.partitionBy.map((partitionBy) => rawOrColumnToSql(ctx, data, partitionBy, quotedAs)).join(", ") : rawOrColumnToSql(ctx, data, window.partitionBy, quotedAs)}`);
|
|
7954
|
+
if (window.partitionBy) sql.push(`PARTITION BY ${Array.isArray(window.partitionBy) ? window.partitionBy.map((partitionBy) => rawOrColumnToSql(ctx, data, data.shape, partitionBy, quotedAs)).join(", ") : rawOrColumnToSql(ctx, data, data.shape, window.partitionBy, quotedAs)}`);
|
|
8006
7955
|
if (window.order) sql.push(`ORDER BY ${orderByToSql(ctx, data, window.order, quotedAs)}`);
|
|
8007
7956
|
return `(${sql.join(" ")})`;
|
|
8008
7957
|
};
|
|
@@ -8069,7 +8018,7 @@ var FnExpression = class extends Expression {
|
|
|
8069
8018
|
const fnArgToSql = (ctx, data, arg, quotedAs) => {
|
|
8070
8019
|
if (typeof arg === "string") {
|
|
8071
8020
|
if (arg.endsWith(".*") || data.valuesJoinedAs?.[arg]) return columnToSql(ctx, data, data.shape, arg, quotedAs);
|
|
8072
|
-
return
|
|
8021
|
+
return columnToSql(ctx, data, data.shape, arg, quotedAs, true);
|
|
8073
8022
|
}
|
|
8074
8023
|
return arg.toSQL(ctx, quotedAs);
|
|
8075
8024
|
};
|
|
@@ -9424,7 +9373,7 @@ var OnConflictQueryBuilder = class {
|
|
|
9424
9373
|
const pushDistinctSql = (ctx, table, distinct, quotedAs) => {
|
|
9425
9374
|
ctx.sql.push("DISTINCT");
|
|
9426
9375
|
if (distinct.length) {
|
|
9427
|
-
const columns = distinct?.map((item) => rawOrColumnToSql(ctx, table.q, item, quotedAs));
|
|
9376
|
+
const columns = distinct?.map((item) => rawOrColumnToSql(ctx, table.q, table.q.shape, item, quotedAs));
|
|
9428
9377
|
ctx.sql.push(`ON (${columns?.join(", ") || ""})`);
|
|
9429
9378
|
}
|
|
9430
9379
|
};
|
|
@@ -12334,7 +12283,7 @@ var ColumnRefExpression = class extends Expression {
|
|
|
12334
12283
|
Object.assign(this, value.operators);
|
|
12335
12284
|
}
|
|
12336
12285
|
makeSQL(ctx, quotedAs) {
|
|
12337
|
-
return
|
|
12286
|
+
return simpleColumnToSQL(ctx, emptyObject, emptyObject, this.name, this.result.value, quotedAs, void 0, void 0, void 0, void 0, true);
|
|
12338
12287
|
}
|
|
12339
12288
|
};
|
|
12340
12289
|
var OrExpression = class extends Expression {
|