sedentary-pg 0.0.32 → 0.0.35
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/dist/cjs/pgdb.js +14 -4
- package/dist/es/pgdb.js +14 -3
- package/package.json +9 -9
package/dist/cjs/pgdb.js
CHANGED
|
@@ -18,10 +18,19 @@ const needDrop = [
|
|
|
18
18
|
const needUsing = [
|
|
19
19
|
["DATETIME", "varchar"],
|
|
20
20
|
["INT", "varchar"],
|
|
21
|
-
["INT8", "varchar"]
|
|
21
|
+
["INT8", "varchar"],
|
|
22
|
+
["NUMBER", "varchar"]
|
|
22
23
|
];
|
|
23
|
-
const types = { int2: "SMALLINT", int4: "INTEGER", int8: "BIGINT", timestamptz: "DATETIME", varchar: "VARCHAR" };
|
|
24
|
+
const types = { int2: "SMALLINT", int4: "INTEGER", int8: "BIGINT", numeric: "NUMERIC", timestamptz: "DATETIME", varchar: "VARCHAR" };
|
|
24
25
|
const actions = { cascade: "c", "no action": "a", restrict: "r", "set default": "d", "set null": "n" };
|
|
26
|
+
function parseInt8(value) {
|
|
27
|
+
return BigInt(value);
|
|
28
|
+
}
|
|
29
|
+
function parseNumber(value) {
|
|
30
|
+
return parseFloat(value);
|
|
31
|
+
}
|
|
32
|
+
pg_1.types.setTypeParser(20, parseInt8);
|
|
33
|
+
pg_1.types.setTypeParser(1700, parseNumber);
|
|
25
34
|
class PGDB extends sedentary_1.DB {
|
|
26
35
|
constructor(connection, log) {
|
|
27
36
|
super(log);
|
|
@@ -278,6 +287,8 @@ class PGDB extends sedentary_1.DB {
|
|
|
278
287
|
switch (type) {
|
|
279
288
|
case "DATETIME":
|
|
280
289
|
return ["DATETIME", "TIMESTAMP (3) WITH TIME ZONE"];
|
|
290
|
+
case "NUMBER":
|
|
291
|
+
return ["NUMERIC", "NUMERIC"];
|
|
281
292
|
case "INT":
|
|
282
293
|
ret = size === 2 ? "SMALLINT" : "INTEGER";
|
|
283
294
|
return [ret, ret];
|
|
@@ -385,7 +396,6 @@ class PGDB extends sedentary_1.DB {
|
|
|
385
396
|
await this.client.query(statement);
|
|
386
397
|
}
|
|
387
398
|
async syncTable(table) {
|
|
388
|
-
var _a;
|
|
389
399
|
if (table.autoIncrement) {
|
|
390
400
|
await (async () => {
|
|
391
401
|
try {
|
|
@@ -438,7 +448,7 @@ class PGDB extends sedentary_1.DB {
|
|
|
438
448
|
if (this.sync)
|
|
439
449
|
await this.client.query(statement);
|
|
440
450
|
const resTable = await this.client.query("SELECT oid FROM pg_class WHERE relname = $1", [table.tableName]);
|
|
441
|
-
table.oid =
|
|
451
|
+
table.oid = resTable.rows[0]?.oid;
|
|
442
452
|
}
|
|
443
453
|
}
|
|
444
454
|
}
|
package/dist/es/pgdb.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DatabaseError, Pool } from "pg";
|
|
1
|
+
import { DatabaseError, Pool, types as PGtypes } from "pg";
|
|
2
2
|
import format from "pg-format";
|
|
3
3
|
import { DB, Transaction } from "sedentary";
|
|
4
4
|
import { adsrc } from "./adsrc";
|
|
@@ -12,10 +12,19 @@ const needDrop = [
|
|
|
12
12
|
const needUsing = [
|
|
13
13
|
["DATETIME", "varchar"],
|
|
14
14
|
["INT", "varchar"],
|
|
15
|
-
["INT8", "varchar"]
|
|
15
|
+
["INT8", "varchar"],
|
|
16
|
+
["NUMBER", "varchar"]
|
|
16
17
|
];
|
|
17
|
-
const types = { int2: "SMALLINT", int4: "INTEGER", int8: "BIGINT", timestamptz: "DATETIME", varchar: "VARCHAR" };
|
|
18
|
+
const types = { int2: "SMALLINT", int4: "INTEGER", int8: "BIGINT", numeric: "NUMERIC", timestamptz: "DATETIME", varchar: "VARCHAR" };
|
|
18
19
|
const actions = { cascade: "c", "no action": "a", restrict: "r", "set default": "d", "set null": "n" };
|
|
20
|
+
function parseInt8(value) {
|
|
21
|
+
return BigInt(value);
|
|
22
|
+
}
|
|
23
|
+
function parseNumber(value) {
|
|
24
|
+
return parseFloat(value);
|
|
25
|
+
}
|
|
26
|
+
PGtypes.setTypeParser(20, parseInt8);
|
|
27
|
+
PGtypes.setTypeParser(1700, parseNumber);
|
|
19
28
|
export class PGDB extends DB {
|
|
20
29
|
client;
|
|
21
30
|
indexes;
|
|
@@ -276,6 +285,8 @@ export class PGDB extends DB {
|
|
|
276
285
|
switch (type) {
|
|
277
286
|
case "DATETIME":
|
|
278
287
|
return ["DATETIME", "TIMESTAMP (3) WITH TIME ZONE"];
|
|
288
|
+
case "NUMBER":
|
|
289
|
+
return ["NUMERIC", "NUMERIC"];
|
|
279
290
|
case "INT":
|
|
280
291
|
ret = size === 2 ? "SMALLINT" : "INTEGER";
|
|
281
292
|
return [ret, ret];
|
package/package.json
CHANGED
|
@@ -9,20 +9,20 @@
|
|
|
9
9
|
"@types/pg": "8.6.5",
|
|
10
10
|
"pg": "8.7.3",
|
|
11
11
|
"pg-format": "1.0.4",
|
|
12
|
-
"sedentary": "0.0.
|
|
12
|
+
"sedentary": "0.0.35"
|
|
13
13
|
},
|
|
14
14
|
"description": "The ORM which never needs to migrate - PostgreSQL",
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/mocha": "9.1.0",
|
|
17
|
-
"@types/node": "17.0.
|
|
17
|
+
"@types/node": "17.0.24",
|
|
18
18
|
"@types/pg-format": "1.0.2",
|
|
19
19
|
"@types/yamljs": "0.2.31",
|
|
20
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
21
|
-
"@typescript-eslint/parser": "5.
|
|
22
|
-
"eslint": "8.
|
|
20
|
+
"@typescript-eslint/eslint-plugin": "5.19.0",
|
|
21
|
+
"@typescript-eslint/parser": "5.19.0",
|
|
22
|
+
"eslint": "8.13.0",
|
|
23
23
|
"mocha": "9.2.2",
|
|
24
24
|
"nyc": "15.1.0",
|
|
25
|
-
"prettier": "2.6.
|
|
25
|
+
"prettier": "2.6.2",
|
|
26
26
|
"ts-node": "10.7.0",
|
|
27
27
|
"typescript": "4.6.3",
|
|
28
28
|
"yamljs": "0.3.0"
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"compilerOptions": {
|
|
72
72
|
"alwaysStrict": true,
|
|
73
73
|
"esModuleInterop": true,
|
|
74
|
-
"moduleResolution": "
|
|
74
|
+
"moduleResolution": "Node",
|
|
75
75
|
"noImplicitAny": true,
|
|
76
76
|
"noImplicitReturns": true,
|
|
77
77
|
"noImplicitThis": true,
|
|
@@ -80,9 +80,9 @@
|
|
|
80
80
|
"strictFunctionTypes": true,
|
|
81
81
|
"strictNullChecks": true,
|
|
82
82
|
"strictPropertyInitialization": true,
|
|
83
|
-
"target": "
|
|
83
|
+
"target": "ESNext"
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
86
|
"types": "./dist/types/index.d.ts",
|
|
87
|
-
"version": "0.0.
|
|
87
|
+
"version": "0.0.35"
|
|
88
88
|
}
|