@palbase/backend 24.0.0 → 24.0.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/bin/palbase-backend.cjs +19 -11
- package/dist/bin/palbase-backend.cjs.map +1 -1
- package/dist/bin/palbase-backend.js +1 -1
- package/dist/{chunk-ZUGY7RGS.js → chunk-LCL7TUAI.js} +1 -1
- package/dist/chunk-LCL7TUAI.js.map +1 -0
- package/dist/{chunk-NXDH6VQJ.js → chunk-YSQBC2VL.js} +20 -12
- package/dist/chunk-YSQBC2VL.js.map +1 -0
- package/dist/db/index.cjs.map +1 -1
- package/dist/db/index.d.cts +1 -1
- package/dist/db/index.d.ts +1 -1
- package/dist/db/index.js +1 -1
- package/dist/engine/index.cjs +19 -11
- package/dist/engine/index.cjs.map +1 -1
- package/dist/engine/index.d.cts +2 -2
- package/dist/engine/index.d.ts +2 -2
- package/dist/engine/index.js +1 -1
- package/dist/{index-CJiJU9ux.d.ts → index-BOS_rFBO.d.ts} +2 -2
- package/dist/{index-DRFxf07H.d.cts → index-C84bLgeO.d.cts} +1 -1
- package/dist/{index-D-4-PNuQ.d.cts → index-MoQ31B6M.d.cts} +2 -2
- package/dist/{index-D17r-MKb.d.ts → index-dJNhDZ7j.d.ts} +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-NXDH6VQJ.js.map +0 -1
- package/dist/chunk-ZUGY7RGS.js.map +0 -1
|
@@ -1374,11 +1374,17 @@ function offsetClause(offset, limit) {
|
|
|
1374
1374
|
}
|
|
1375
1375
|
function compileWhere(table, colSet, where, add, caller = "search") {
|
|
1376
1376
|
const parts = [];
|
|
1377
|
+
const transforms = transformsOf(currentSchema, table);
|
|
1378
|
+
const bindFor = (col) => {
|
|
1379
|
+
const t = transforms.get(col);
|
|
1380
|
+
return t?.toDb === void 0 ? add : (v) => add(v === null || v === void 0 ? v : t.toDb(v));
|
|
1381
|
+
};
|
|
1377
1382
|
for (const [col, cond] of Object.entries(where)) {
|
|
1378
1383
|
if (colSet !== null && !colSet.has(col)) {
|
|
1379
1384
|
throw new Error(`${caller}(${table}): where kolonu "${col}" tabloda yok (FR-016)`);
|
|
1380
1385
|
}
|
|
1381
1386
|
const q = `t.${quoteIdent(col)}`;
|
|
1387
|
+
const bind = bindFor(col);
|
|
1382
1388
|
if (cond !== null && typeof cond === "object" && !Array.isArray(cond)) {
|
|
1383
1389
|
for (const [op, v] of Object.entries(cond)) {
|
|
1384
1390
|
if (op === "in") {
|
|
@@ -1387,15 +1393,15 @@ function compileWhere(table, colSet, where, add, caller = "search") {
|
|
|
1387
1393
|
parts.push("false");
|
|
1388
1394
|
continue;
|
|
1389
1395
|
}
|
|
1390
|
-
parts.push(`${q} IN (${v.map((x) =>
|
|
1396
|
+
parts.push(`${q} IN (${v.map((x) => bind(x)).join(", ")})`);
|
|
1391
1397
|
} else if (op in WHERE_OPS) {
|
|
1392
|
-
parts.push(`${q} ${WHERE_OPS[op]} ${
|
|
1398
|
+
parts.push(`${q} ${WHERE_OPS[op]} ${bind(v)}`);
|
|
1393
1399
|
} else {
|
|
1394
1400
|
throw new Error(`${caller}(${table}): where.${col} bilinmeyen operat\xF6r "${op}" (gt/gte/lt/lte/neq/in)`);
|
|
1395
1401
|
}
|
|
1396
1402
|
}
|
|
1397
1403
|
} else {
|
|
1398
|
-
parts.push(`${q} = ${
|
|
1404
|
+
parts.push(`${q} = ${bind(cond)}`);
|
|
1399
1405
|
}
|
|
1400
1406
|
}
|
|
1401
1407
|
return parts.length === 0 ? "" : ` AND ${parts.join(" AND ")}`;
|
|
@@ -1594,10 +1600,9 @@ function createOps(tx) {
|
|
|
1594
1600
|
*/
|
|
1595
1601
|
async updateMany(table, where, set) {
|
|
1596
1602
|
const cols = Object.keys(set);
|
|
1597
|
-
if (cols.length === 0)
|
|
1598
|
-
if (Object.keys(where).length === 0) {
|
|
1603
|
+
if (cols.length === 0) {
|
|
1599
1604
|
throw new Error(
|
|
1600
|
-
`updateMany(${table}):
|
|
1605
|
+
`updateMany(${table}): nothing to set. An update with no columns is not a no-op worth pretending happened \u2014 pass the columns to write.`
|
|
1601
1606
|
);
|
|
1602
1607
|
}
|
|
1603
1608
|
const params = [];
|
|
@@ -1608,6 +1613,7 @@ function createOps(tx) {
|
|
|
1608
1613
|
const assignments = cols.map((c) => `${quoteIdent(c)} = ${add(asBindParams(table, [c], set)[0])}`).join(", ");
|
|
1609
1614
|
const known = schemaColumns(table);
|
|
1610
1615
|
const whereSql = compileWhere(table, known, where, add, "updateMany");
|
|
1616
|
+
assertHasPredicate(whereSql, "updateMany", table);
|
|
1611
1617
|
const sql = `UPDATE ${quoteIdent(table)} AS t SET ${assignments} WHERE true${whereSql} RETURNING *`;
|
|
1612
1618
|
return asTableRows(table, await (await at()).unsafe(sql, params));
|
|
1613
1619
|
},
|
|
@@ -1617,11 +1623,6 @@ function createOps(tx) {
|
|
|
1617
1623
|
* {@link updateMany} — and here the accident is worse.
|
|
1618
1624
|
*/
|
|
1619
1625
|
async deleteMany(table, where) {
|
|
1620
|
-
if (Object.keys(where).length === 0) {
|
|
1621
|
-
throw new Error(
|
|
1622
|
-
`deleteMany(${table}): bo\u015F filtre T\xDCM sat\u0131rlar\u0131 silerdi \u2014 bir filtre verin, ya da her sat\u0131ra uyan bir ko\u015Ful yaz\u0131n`
|
|
1623
|
-
);
|
|
1624
|
-
}
|
|
1625
1626
|
const params = [];
|
|
1626
1627
|
const add = (v) => {
|
|
1627
1628
|
params.push(v);
|
|
@@ -1629,6 +1630,7 @@ function createOps(tx) {
|
|
|
1629
1630
|
};
|
|
1630
1631
|
const known = schemaColumns(table);
|
|
1631
1632
|
const whereSql = compileWhere(table, known, where, add, "deleteMany");
|
|
1633
|
+
assertHasPredicate(whereSql, "deleteMany", table);
|
|
1632
1634
|
const sql = `DELETE FROM ${quoteIdent(table)} AS t WHERE true${whereSql} RETURNING 1`;
|
|
1633
1635
|
const rows = await (await at()).unsafe(sql, params);
|
|
1634
1636
|
return rows.length;
|
|
@@ -2179,6 +2181,12 @@ function isAbortedTransaction(e) {
|
|
|
2179
2181
|
const message = String(e?.message ?? "");
|
|
2180
2182
|
return sqlstateOf(e) === "25P02" || /current transaction is aborted/i.test(message);
|
|
2181
2183
|
}
|
|
2184
|
+
function assertHasPredicate(whereSql, op, table) {
|
|
2185
|
+
if (whereSql.trim().length > 0) return;
|
|
2186
|
+
throw new Error(
|
|
2187
|
+
`${op}(${table}): the filter compiled to no condition, so this would have written EVERY row. An empty filter \u2014 or an operator object with no operators in it, like { col: {} } \u2014 is refused. Name a condition.`
|
|
2188
|
+
);
|
|
2189
|
+
}
|
|
2182
2190
|
function sqlstateOf(e) {
|
|
2183
2191
|
const err = e;
|
|
2184
2192
|
const isState = (v) => typeof v === "string" && /^[0-9A-Z]{5}$/.test(v);
|