@saltcorn/sql 0.5.6 → 0.5.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/package.json +1 -1
- package/table-provider.js +10 -2
package/package.json
CHANGED
package/table-provider.js
CHANGED
|
@@ -443,6 +443,8 @@ const countRows = async (cfg, where, opts) => {
|
|
|
443
443
|
});
|
|
444
444
|
|
|
445
445
|
const qctx = {};
|
|
446
|
+
const ensure_no_final_semicolon = (s) =>
|
|
447
|
+
s.trim().endsWith(";") ? s.trim().slice(0, -1) : s;
|
|
446
448
|
|
|
447
449
|
if (opts?.forUser) qctx.user = sqlEscapeObject(opts.forUser);
|
|
448
450
|
else if (where?.forUser)
|
|
@@ -465,8 +467,14 @@ const countRows = async (cfg, where, opts) => {
|
|
|
465
467
|
}
|
|
466
468
|
|
|
467
469
|
//console.trace({ sqlQ, phValues, opts });
|
|
468
|
-
db.sql_log(
|
|
469
|
-
|
|
470
|
+
db.sql_log(
|
|
471
|
+
`select count(*) from (${ensure_no_final_semicolon(sqlQ)})`,
|
|
472
|
+
phValues
|
|
473
|
+
);
|
|
474
|
+
const qres = await client.query(
|
|
475
|
+
`select count(*) from (${ensure_no_final_semicolon(sqlQ)})`,
|
|
476
|
+
phValues
|
|
477
|
+
);
|
|
470
478
|
qres.query = sqlQ;
|
|
471
479
|
db.sql_log("ROLLBACK;");
|
|
472
480
|
await client.query(`ROLLBACK;`);
|