@saltcorn/sql 0.4.2 → 0.4.3

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.
Files changed (2) hide show
  1. package/action.js +12 -4
  2. package/package.json +1 -1
package/action.js CHANGED
@@ -20,6 +20,13 @@ module.exports = {
20
20
  "Comma separated list of row variables to use as SQL query parameters. User variables can be used as <code>user.id</code> etc",
21
21
  type: "String",
22
22
  },
23
+ {
24
+ name: "read_only",
25
+ label: "Read only",
26
+ sublabel: "Run the SQL in a read-only transactions",
27
+ type: "Bool",
28
+ },
29
+
23
30
  ...(mode === "workflow"
24
31
  ? [
25
32
  {
@@ -35,7 +42,7 @@ module.exports = {
35
42
  ],
36
43
  run: async ({
37
44
  row,
38
- configuration: { sql, row_parameters, results_variable },
45
+ configuration: { sql, row_parameters, read_only, results_variable },
39
46
  user,
40
47
  mode,
41
48
  }) => {
@@ -59,9 +66,10 @@ module.exports = {
59
66
  await client.query(
60
67
  `SET LOCAL search_path TO "${db.getTenantSchema()}";`
61
68
  );
62
- await client.query(
63
- `SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;`
64
- );
69
+ if (read_only)
70
+ await client.query(
71
+ `SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY;`
72
+ );
65
73
  }
66
74
  const qres = await client.query(sql, phValues);
67
75
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/sql",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Actions and views based on SQL",
5
5
  "main": "index.js",
6
6
  "dependencies": {