pqb 0.30.6 → 0.30.7
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 +22 -30
- package/dist/index.js +19 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExpressionTypeMethod, Expression, RawSQLBase, emptyObject, isTemplateLiteralArgs, ColumnTypeBase, setColumnData, pushColumnData, quoteObjectKey, toArray, singleQuote, addCode, singleQuoteArray, objectHasValues, columnDefaultArgumentToCode, columnErrorMessagesToCode, getValueKey, addValue, isExpression, joinTruthy, numberDataToCode, stringDataToCode, getDefaultLanguage, dateDataToCode, pushOrNewArrayToObject, noop, arrayDataToCode, emptyArray, callWithThis, setParserToQuery, applyTransforms, isRawSQL, pushOrNewArray, setDefaultNowFn, setDefaultLanguage, makeTimestampsHelpers, setCurrentColumnName, setAdapterConnectRetry, isObjectEmpty, ValExpression, applyMixins, toSnakeCase, snakeCaseKey } from 'orchid-core';
|
|
1
|
+
import { ExpressionTypeMethod, Expression, RawSQLBase, emptyObject, isTemplateLiteralArgs, ColumnTypeBase, setColumnData, pushColumnData, quoteObjectKey, toArray, singleQuote, addCode, singleQuoteArray, objectHasValues, columnDefaultArgumentToCode, columnErrorMessagesToCode, getValueKey, addValue, isExpression, joinTruthy, numberDataToCode, stringDataToCode, getDefaultLanguage, dateDataToCode, pushOrNewArrayToObject, returnArg as returnArg$1, noop, arrayDataToCode, emptyArray, callWithThis, setParserToQuery, applyTransforms, isRawSQL, pushOrNewArray, setDefaultNowFn, setDefaultLanguage, makeTimestampsHelpers, setCurrentColumnName, setAdapterConnectRetry, isObjectEmpty, ValExpression, applyMixins, toSnakeCase, snakeCaseKey } from 'orchid-core';
|
|
2
2
|
import pg from 'pg';
|
|
3
3
|
import { inspect } from 'node:util';
|
|
4
4
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
@@ -2377,25 +2377,14 @@ const subJoinToSql = (ctx, jq, innerAs, outerAs, cloned) => {
|
|
|
2377
2377
|
}).text}) ${outerAs || innerAs}`;
|
|
2378
2378
|
};
|
|
2379
2379
|
const processArgs = (args, ctx, query, joinAs, joinShape, quotedAs) => {
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
);
|
|
2389
|
-
} else {
|
|
2390
|
-
return getConditionsFor3Or4LengthItem(
|
|
2391
|
-
ctx,
|
|
2392
|
-
query,
|
|
2393
|
-
joinAs,
|
|
2394
|
-
quotedAs,
|
|
2395
|
-
args,
|
|
2396
|
-
joinShape
|
|
2397
|
-
);
|
|
2398
|
-
}
|
|
2380
|
+
return args.length === 1 ? getObjectOrRawConditions(ctx, query, args[0], quotedAs, joinAs, joinShape) : getConditionsFor3Or4LengthItem(
|
|
2381
|
+
ctx,
|
|
2382
|
+
query,
|
|
2383
|
+
joinAs,
|
|
2384
|
+
quotedAs,
|
|
2385
|
+
args,
|
|
2386
|
+
joinShape
|
|
2387
|
+
);
|
|
2399
2388
|
};
|
|
2400
2389
|
const getConditionsFor3Or4LengthItem = (ctx, query, target, quotedAs, args, joinShape) => {
|
|
2401
2390
|
const [leftColumn, opOrRightColumn, maybeRightColumn] = args;
|
|
@@ -2548,7 +2537,9 @@ const processJoinArgs = (joinTo, first, args, joinSubQuery) => {
|
|
|
2548
2537
|
);
|
|
2549
2538
|
return { w: first, r, s: joinSubQuery || getIsJoinSubQuery(r) };
|
|
2550
2539
|
}
|
|
2551
|
-
}
|
|
2540
|
+
}
|
|
2541
|
+
const args0 = args.length ? args[0] : returnArg$1;
|
|
2542
|
+
if (typeof args0 === "function") {
|
|
2552
2543
|
const q = first;
|
|
2553
2544
|
if (q.joinQueryAfterCallback) {
|
|
2554
2545
|
let base = q.baseQuery;
|
|
@@ -2566,7 +2557,7 @@ const processJoinArgs = (joinTo, first, args, joinSubQuery) => {
|
|
|
2566
2557
|
const joinedShapes = __spreadProps$4(__spreadValues$c({}, joinTo.q.joinedShapes), {
|
|
2567
2558
|
[joinTo.q.as || joinTo.table]: joinTo.shape
|
|
2568
2559
|
});
|
|
2569
|
-
const r =
|
|
2560
|
+
const r = args0(
|
|
2570
2561
|
makeJoinQueryBuilder(
|
|
2571
2562
|
q,
|
|
2572
2563
|
q.q.joinedShapes ? __spreadValues$c(__spreadValues$c({}, q.q.joinedShapes), joinedShapes) : joinedShapes,
|
|
@@ -6364,7 +6355,7 @@ class Create {
|
|
|
6364
6355
|
*
|
|
6365
6356
|
* await db.table.create({
|
|
6366
6357
|
* // raw SQL
|
|
6367
|
-
* column1: sql`'John' || ' ' || 'Doe'`,
|
|
6358
|
+
* column1: (q) => q.sql`'John' || ' ' || 'Doe'`,
|
|
6368
6359
|
*
|
|
6369
6360
|
* // query that returns a single value
|
|
6370
6361
|
* // returning multiple values will result in Postgres error
|
|
@@ -9440,7 +9431,7 @@ class Update {
|
|
|
9440
9431
|
* column1: 123,
|
|
9441
9432
|
*
|
|
9442
9433
|
* // use raw SQL to update the column
|
|
9443
|
-
* column2: sql`2 + 2`,
|
|
9434
|
+
* column2: (q) => q.sql`2 + 2`,
|
|
9444
9435
|
*
|
|
9445
9436
|
* // use query that returns a single value
|
|
9446
9437
|
* // returning multiple values will result in Postgres error
|
|
@@ -9554,7 +9545,7 @@ class Update {
|
|
|
9554
9545
|
);
|
|
9555
9546
|
}
|
|
9556
9547
|
/**
|
|
9557
|
-
* `
|
|
9548
|
+
* `updateSql` is for updating records with raw expression.
|
|
9558
9549
|
*
|
|
9559
9550
|
* The behavior is the same as a regular `update` method has:
|
|
9560
9551
|
* `find` or `where` must precede calling this method,
|
|
@@ -9565,14 +9556,14 @@ class Update {
|
|
|
9565
9556
|
* const value = 'new name';
|
|
9566
9557
|
*
|
|
9567
9558
|
* // update with SQL template string
|
|
9568
|
-
* const updatedCount = await db.table.find(1).
|
|
9559
|
+
* const updatedCount = await db.table.find(1).updateSql`name = ${value}`;
|
|
9569
9560
|
*
|
|
9570
9561
|
* // or update with `sql` function:
|
|
9571
|
-
* await db.table.find(1).
|
|
9562
|
+
* await db.table.find(1).updateSql(sql`name = ${value}`);
|
|
9572
9563
|
* ```
|
|
9573
9564
|
* @param args - raw SQL via a template string or by using a `sql` method
|
|
9574
9565
|
*/
|
|
9575
|
-
|
|
9566
|
+
updateSql(...args) {
|
|
9576
9567
|
return _queryUpdateRaw(
|
|
9577
9568
|
this.clone(),
|
|
9578
9569
|
sqlQueryArgsToExpression(args)
|
|
@@ -11147,10 +11138,7 @@ class QueryMethods {
|
|
|
11147
11138
|
* pets: (q) => q.pets.join().none(),
|
|
11148
11139
|
* });
|
|
11149
11140
|
*
|
|
11150
|
-
* await db.user.join(
|
|
11151
|
-
* (q) => q.pets.none(),
|
|
11152
|
-
* (q) => q,
|
|
11153
|
-
* );
|
|
11141
|
+
* await db.user.join((q) => q.pets.none());
|
|
11154
11142
|
*
|
|
11155
11143
|
* await db.user.join('pets', (q) => q.none());
|
|
11156
11144
|
* ```
|