@saltcorn/postgres 1.3.1-beta.1 → 1.3.1-beta.11
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 +3 -2
- package/postgres.js +15 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saltcorn/postgres",
|
|
3
|
-
"version": "1.3.1-beta.
|
|
3
|
+
"version": "1.3.1-beta.11",
|
|
4
4
|
"description": "Postgres structures for Saltcorn, open-source no-code platform",
|
|
5
5
|
"homepage": "https://saltcorn.com",
|
|
6
6
|
"scripts": {
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"main": "index.js",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@saltcorn/db-common": "1.3.1-beta.
|
|
15
|
+
"@saltcorn/db-common": "1.3.1-beta.11",
|
|
16
|
+
"@saltcorn/plain-date": "0.1.4",
|
|
16
17
|
"pg": "^8.13.1",
|
|
17
18
|
"pg-copy-streams": "^6.0.6",
|
|
18
19
|
"replacestream": "4.0.3"
|
package/postgres.js
CHANGED
|
@@ -15,6 +15,12 @@ const {
|
|
|
15
15
|
mkWhere,
|
|
16
16
|
mkSelectOptions,
|
|
17
17
|
} = require("@saltcorn/db-common/internal");
|
|
18
|
+
const PlainDate = require("@saltcorn/plain-date");
|
|
19
|
+
|
|
20
|
+
var types = require("pg").types;
|
|
21
|
+
types.setTypeParser(types.builtins.DATE, (d) =>
|
|
22
|
+
d === null ? null : new PlainDate(d)
|
|
23
|
+
);
|
|
18
24
|
|
|
19
25
|
let getTenantSchema;
|
|
20
26
|
let getRequestContext;
|
|
@@ -591,6 +597,14 @@ const withTransaction = async (f, onError) => {
|
|
|
591
597
|
}
|
|
592
598
|
};
|
|
593
599
|
|
|
600
|
+
const commitAndBeginNewTransaction = async () => {
|
|
601
|
+
const client = await getClient();
|
|
602
|
+
sql_log("COMMIT;");
|
|
603
|
+
await client.query("COMMIT;");
|
|
604
|
+
sql_log("BEGIN;");
|
|
605
|
+
await client.query("BEGIN;");
|
|
606
|
+
};
|
|
607
|
+
|
|
594
608
|
const tryCatchInTransaction = async (f, onError) => {
|
|
595
609
|
const rndid = Math.floor(Math.random() * 16777215).toString(16);
|
|
596
610
|
const reqCon = getRequestContext();
|
|
@@ -655,6 +669,7 @@ const postgresExports = {
|
|
|
655
669
|
truncate,
|
|
656
670
|
withTransaction,
|
|
657
671
|
tryCatchInTransaction,
|
|
672
|
+
commitAndBeginNewTransaction,
|
|
658
673
|
};
|
|
659
674
|
|
|
660
675
|
module.exports = (getConnectObjectPara) => {
|