pqb 0.0.9 → 0.1.0
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.esm.js +13 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +13 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/sql/select.ts +19 -12
package/dist/index.esm.js
CHANGED
|
@@ -2507,7 +2507,7 @@ const selectToSql = (model, query, values, quotedAs) => {
|
|
|
2507
2507
|
if (query.select) {
|
|
2508
2508
|
const list = [];
|
|
2509
2509
|
query.select.forEach((item) => {
|
|
2510
|
-
var _a2, _b
|
|
2510
|
+
var _a2, _b;
|
|
2511
2511
|
if (typeof item === "string") {
|
|
2512
2512
|
list.push(
|
|
2513
2513
|
item === "*" ? ((_a2 = query.join) == null ? void 0 : _a2.length) ? `${quotedAs}.*` : "*" : quoteFullColumn(item, quotedAs)
|
|
@@ -2524,18 +2524,20 @@ const selectToSql = (model, query, values, quotedAs) => {
|
|
|
2524
2524
|
relationQuery = relationQuery._json();
|
|
2525
2525
|
break;
|
|
2526
2526
|
case "pluck": {
|
|
2527
|
-
const
|
|
2528
|
-
|
|
2527
|
+
const { select } = relationQuery.query;
|
|
2528
|
+
const first = select == null ? void 0 : select[0];
|
|
2529
|
+
if (!select || !first) {
|
|
2529
2530
|
throw new PormInternalError(`Nothing was selected for pluck`);
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2531
|
+
}
|
|
2532
|
+
select.length = 0;
|
|
2533
|
+
select[0] = { selectAs: { c: first } };
|
|
2534
|
+
relationQuery = relationQuery._wrap(
|
|
2535
|
+
relationQuery.__model.clone()
|
|
2536
|
+
);
|
|
2537
|
+
relationQuery._getOptional(
|
|
2538
|
+
raw(`COALESCE(json_agg("c"), '[]')`)
|
|
2535
2539
|
);
|
|
2536
|
-
relationQuery.query.
|
|
2537
|
-
raw(`COALESCE(json_agg(${selection}), '[]')`)
|
|
2538
|
-
];
|
|
2540
|
+
delete relationQuery.query.take;
|
|
2539
2541
|
break;
|
|
2540
2542
|
}
|
|
2541
2543
|
case "rows":
|