@saltcorn/sql 0.3.7 → 0.3.9
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 +21 -0
- package/package.json +1 -1
- package/terminal.js +0 -1
package/index.js
CHANGED
|
@@ -133,6 +133,27 @@ module.exports = {
|
|
|
133
133
|
plugin_name: "sql",
|
|
134
134
|
actions: require("./action.js"),
|
|
135
135
|
table_providers: require("./table-provider.js"),
|
|
136
|
+
functions: {
|
|
137
|
+
sqlQuery: {
|
|
138
|
+
run: async (query, parameters) => {
|
|
139
|
+
const is_sqlite = db.isSQLite;
|
|
140
|
+
|
|
141
|
+
const client = is_sqlite ? db : await db.getClient();
|
|
142
|
+
await client.query(`BEGIN;`);
|
|
143
|
+
if (!is_sqlite) {
|
|
144
|
+
await client.query(
|
|
145
|
+
`SET LOCAL search_path TO "${db.getTenantSchema()}";`
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
const qres = await db.query(query, parameters || []);
|
|
149
|
+
|
|
150
|
+
await client.query(`COMMIT;`);
|
|
151
|
+
return qres;
|
|
152
|
+
},
|
|
153
|
+
isAsync: true,
|
|
154
|
+
description: "Run an SQL query",
|
|
155
|
+
},
|
|
156
|
+
},
|
|
136
157
|
viewtemplates: [
|
|
137
158
|
{
|
|
138
159
|
name: "SQLView",
|
package/package.json
CHANGED
package/terminal.js
CHANGED