pqb 0.48.1 → 0.48.3
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 -1
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5512,7 +5512,9 @@ type SelectArg<T extends SelectSelf> = '*' | keyof T['meta']['selectable'];
|
|
|
5512
5512
|
type SelectArgs<T extends SelectSelf> = ('*' | keyof T['meta']['selectable'])[];
|
|
5513
5513
|
interface SelectAsArg<T extends SelectSelf> {
|
|
5514
5514
|
[K: string]: keyof T['meta']['selectable'] | Expression | ((q: EmptyObject extends T['relations'] ? T : {
|
|
5515
|
-
[K in keyof T['relations'] | keyof T]: K extends keyof T['relations'] ? T['relations'][K]['relationConfig']['maybeSingle']
|
|
5515
|
+
[K in keyof T['relations'] | keyof T]: K extends keyof T['relations'] ? T['relations'][K]['relationConfig']['maybeSingle'] & {
|
|
5516
|
+
withData: T['withData'];
|
|
5517
|
+
} : K extends keyof T ? T[K] : never;
|
|
5516
5518
|
}) => unknown);
|
|
5517
5519
|
}
|
|
5518
5520
|
type SelectAsFnReturnType = {
|
package/dist/index.js
CHANGED
|
@@ -2101,6 +2101,7 @@ const tableColumnToSqlWithAs = (ctx, data, column, table, key, as, quotedAs, sel
|
|
|
2101
2101
|
const tableName = data.aliases?.[table] || table;
|
|
2102
2102
|
const quoted = `"${table}"`;
|
|
2103
2103
|
const col = quoted === quotedAs ? data.shape[key] : data.joinedShapes?.[tableName][key];
|
|
2104
|
+
if (jsonList) jsonList[as] = col;
|
|
2104
2105
|
if (col) {
|
|
2105
2106
|
if (col.data.name && col.data.name !== key) {
|
|
2106
2107
|
return `"${tableName}"."${col.data.name}" "${as}"`;
|
|
@@ -2115,11 +2116,11 @@ const tableColumnToSqlWithAs = (ctx, data, column, table, key, as, quotedAs, sel
|
|
|
2115
2116
|
)} "${as}"`;
|
|
2116
2117
|
}
|
|
2117
2118
|
}
|
|
2118
|
-
if (jsonList) jsonList[as] = col;
|
|
2119
2119
|
return `"${tableName}"."${key}"${key === as ? "" : ` "${as}"`}`;
|
|
2120
2120
|
};
|
|
2121
2121
|
const ownColumnToSqlWithAs = (ctx, data, column, as, quotedAs, select, jsonList) => {
|
|
2122
2122
|
const col = data.shape[column];
|
|
2123
|
+
if (jsonList) jsonList[as] = col;
|
|
2123
2124
|
if (col) {
|
|
2124
2125
|
if (col.data.name && col.data.name !== column) {
|
|
2125
2126
|
return `${quotedAs ? `${quotedAs}.` : ""}"${col.data.name}"${col.data.name === as ? "" : ` "${as}"`}`;
|
|
@@ -2134,7 +2135,6 @@ const ownColumnToSqlWithAs = (ctx, data, column, as, quotedAs, select, jsonList)
|
|
|
2134
2135
|
)} "${as}"`;
|
|
2135
2136
|
}
|
|
2136
2137
|
}
|
|
2137
|
-
if (jsonList) jsonList[as] = col;
|
|
2138
2138
|
return `${quotedAs ? `${quotedAs}.` : ""}"${column}"${column === as ? "" : ` "${as}"`}`;
|
|
2139
2139
|
};
|
|
2140
2140
|
const rawOrColumnToSql = (ctx, data, expr, quotedAs, shape = data.shape, select) => {
|
|
@@ -5307,7 +5307,7 @@ const pushUpdateSql = (ctx, table, query, quotedAs) => {
|
|
|
5307
5307
|
}
|
|
5308
5308
|
ctx.sql.push(`UPDATE ${quotedTable}`);
|
|
5309
5309
|
if (quotedTable !== quotedAs) {
|
|
5310
|
-
ctx.sql.push(
|
|
5310
|
+
ctx.sql.push(quotedAs);
|
|
5311
5311
|
}
|
|
5312
5312
|
ctx.sql.push("SET");
|
|
5313
5313
|
ctx.sql.push(set.join(", "));
|
|
@@ -5379,7 +5379,7 @@ const pushDeleteSql = (ctx, table, query, quotedAs) => {
|
|
|
5379
5379
|
const from = `"${table.table}"`;
|
|
5380
5380
|
ctx.sql.push(`DELETE FROM ${from}`);
|
|
5381
5381
|
if (from !== quotedAs) {
|
|
5382
|
-
ctx.sql.push(
|
|
5382
|
+
ctx.sql.push(quotedAs);
|
|
5383
5383
|
}
|
|
5384
5384
|
let conditions;
|
|
5385
5385
|
if (query.join?.length) {
|
|
@@ -5868,7 +5868,7 @@ const processJoinItem = (ctx, table, query, args, quotedAs) => {
|
|
|
5868
5868
|
const as = j.q.as;
|
|
5869
5869
|
const joinAs = `"${as}"`;
|
|
5870
5870
|
if (as !== tableName) {
|
|
5871
|
-
target += `
|
|
5871
|
+
target += ` ${joinAs}`;
|
|
5872
5872
|
}
|
|
5873
5873
|
if (r && s) {
|
|
5874
5874
|
target = `LATERAL ${subJoinToSql(ctx, j, quotedTable, joinAs, true)}`;
|
|
@@ -5963,7 +5963,7 @@ const getArgQueryTarget = (ctx, first, joinSubQuery, cloned) => {
|
|
|
5963
5963
|
let target = quotedFrom || quoteSchemaAndTable(joinQuery.schema, first.table);
|
|
5964
5964
|
if (addAs) {
|
|
5965
5965
|
joinAs = qAs;
|
|
5966
|
-
target += `
|
|
5966
|
+
target += ` ${qAs}`;
|
|
5967
5967
|
}
|
|
5968
5968
|
return { target, joinAs };
|
|
5969
5969
|
}
|
|
@@ -7034,7 +7034,9 @@ const resolveSubQueryCallbackV2 = (q, cb) => {
|
|
|
7034
7034
|
Object.defineProperty(base, key, {
|
|
7035
7035
|
get() {
|
|
7036
7036
|
const rel = relations[key].relationConfig;
|
|
7037
|
-
|
|
7037
|
+
const relQuery = _clone(rel.query);
|
|
7038
|
+
relQuery.q.withShapes = this.q.withShapes;
|
|
7039
|
+
return _chain(this, relQuery, rel);
|
|
7038
7040
|
}
|
|
7039
7041
|
});
|
|
7040
7042
|
}
|
|
@@ -12747,7 +12749,7 @@ class Db extends QueryMethods {
|
|
|
12747
12749
|
const column = shape[key];
|
|
12748
12750
|
if (!column.data.explicitSelect) {
|
|
12749
12751
|
list.push(
|
|
12750
|
-
column.data.name ? `"${column.data.name}"
|
|
12752
|
+
column.data.name ? `"${column.data.name}" "${key}"` : `"${key}"`
|
|
12751
12753
|
);
|
|
12752
12754
|
keys[key] = column;
|
|
12753
12755
|
}
|