@saltcorn/sql 0.4.3 → 0.4.4
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/index.js +16 -11
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -96,18 +96,23 @@ const run = async (
|
|
|
96
96
|
} else if (typeof state[sp] === "undefined") phValues.push(null);
|
|
97
97
|
else phValues.push(state[sp]);
|
|
98
98
|
});
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
let qres, client;
|
|
100
|
+
try {
|
|
101
|
+
client = is_sqlite ? db : await db.getClient();
|
|
102
|
+
await client.query(`BEGIN;`);
|
|
103
|
+
if (!is_sqlite) {
|
|
104
|
+
await client.query(`SET LOCAL search_path TO "${db.getTenantSchema()}";`);
|
|
105
|
+
await client.query(
|
|
106
|
+
`SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;`
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
qres = await client.query(sql, phValues);
|
|
110
|
+
} catch (e) {
|
|
111
|
+
throw e;
|
|
112
|
+
} finally {
|
|
113
|
+
await client.query(`ROLLBACK;`);
|
|
114
|
+
if (!is_sqlite) client.release(true);
|
|
105
115
|
}
|
|
106
|
-
const qres = await client.query(sql, phValues);
|
|
107
|
-
|
|
108
|
-
await client.query(`ROLLBACK;`);
|
|
109
|
-
|
|
110
|
-
if (!is_sqlite) client.release(true);
|
|
111
116
|
switch (output_type) {
|
|
112
117
|
case "HTML":
|
|
113
118
|
const template = _.template(html_code || "", {
|