sedentary-pg 0.0.33 → 0.0.36

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 CHANGED
@@ -16,16 +16,22 @@ const needDrop = [
16
16
  ["INT8", "timestamptz"]
17
17
  ];
18
18
  const needUsing = [
19
+ ["BOOLEAN", "varchar"],
19
20
  ["DATETIME", "varchar"],
20
21
  ["INT", "varchar"],
21
- ["INT8", "varchar"]
22
+ ["INT8", "varchar"],
23
+ ["NUMBER", "varchar"]
22
24
  ];
23
- const types = { int2: "SMALLINT", int4: "INTEGER", int8: "BIGINT", timestamptz: "DATETIME", varchar: "VARCHAR" };
25
+ const types = { bool: "BOOL", int2: "SMALLINT", int4: "INTEGER", int8: "BIGINT", numeric: "NUMERIC", timestamptz: "DATETIME", varchar: "VARCHAR" };
24
26
  const actions = { cascade: "c", "no action": "a", restrict: "r", "set default": "d", "set null": "n" };
25
27
  function parseInt8(value) {
26
28
  return BigInt(value);
27
29
  }
30
+ function parseNumber(value) {
31
+ return parseFloat(value);
32
+ }
28
33
  pg_1.types.setTypeParser(20, parseInt8);
34
+ pg_1.types.setTypeParser(1700, parseNumber);
29
35
  class PGDB extends sedentary_1.DB {
30
36
  constructor(connection, log) {
31
37
  super(log);
@@ -280,8 +286,12 @@ class PGDB extends sedentary_1.DB {
280
286
  const { size, type } = attribute;
281
287
  let ret;
282
288
  switch (type) {
289
+ case "BOOLEAN":
290
+ return ["BOOL", "BOOL"];
283
291
  case "DATETIME":
284
292
  return ["DATETIME", "TIMESTAMP (3) WITH TIME ZONE"];
293
+ case "NUMBER":
294
+ return ["NUMERIC", "NUMERIC"];
285
295
  case "INT":
286
296
  ret = size === 2 ? "SMALLINT" : "INTEGER";
287
297
  return [ret, ret];
@@ -389,7 +399,6 @@ class PGDB extends sedentary_1.DB {
389
399
  await this.client.query(statement);
390
400
  }
391
401
  async syncTable(table) {
392
- var _a;
393
402
  if (table.autoIncrement) {
394
403
  await (async () => {
395
404
  try {
@@ -442,7 +451,7 @@ class PGDB extends sedentary_1.DB {
442
451
  if (this.sync)
443
452
  await this.client.query(statement);
444
453
  const resTable = await this.client.query("SELECT oid FROM pg_class WHERE relname = $1", [table.tableName]);
445
- table.oid = (_a = resTable.rows[0]) === null || _a === void 0 ? void 0 : _a.oid;
454
+ table.oid = resTable.rows[0]?.oid;
446
455
  }
447
456
  }
448
457
  }
package/dist/es/pgdb.js CHANGED
@@ -10,16 +10,22 @@ const needDrop = [
10
10
  ["INT8", "timestamptz"]
11
11
  ];
12
12
  const needUsing = [
13
+ ["BOOLEAN", "varchar"],
13
14
  ["DATETIME", "varchar"],
14
15
  ["INT", "varchar"],
15
- ["INT8", "varchar"]
16
+ ["INT8", "varchar"],
17
+ ["NUMBER", "varchar"]
16
18
  ];
17
- const types = { int2: "SMALLINT", int4: "INTEGER", int8: "BIGINT", timestamptz: "DATETIME", varchar: "VARCHAR" };
19
+ const types = { bool: "BOOL", int2: "SMALLINT", int4: "INTEGER", int8: "BIGINT", numeric: "NUMERIC", timestamptz: "DATETIME", varchar: "VARCHAR" };
18
20
  const actions = { cascade: "c", "no action": "a", restrict: "r", "set default": "d", "set null": "n" };
19
21
  function parseInt8(value) {
20
22
  return BigInt(value);
21
23
  }
24
+ function parseNumber(value) {
25
+ return parseFloat(value);
26
+ }
22
27
  PGtypes.setTypeParser(20, parseInt8);
28
+ PGtypes.setTypeParser(1700, parseNumber);
23
29
  export class PGDB extends DB {
24
30
  client;
25
31
  indexes;
@@ -278,8 +284,12 @@ export class PGDB extends DB {
278
284
  const { size, type } = attribute;
279
285
  let ret;
280
286
  switch (type) {
287
+ case "BOOLEAN":
288
+ return ["BOOL", "BOOL"];
281
289
  case "DATETIME":
282
290
  return ["DATETIME", "TIMESTAMP (3) WITH TIME ZONE"];
291
+ case "NUMBER":
292
+ return ["NUMERIC", "NUMERIC"];
283
293
  case "INT":
284
294
  ret = size === 2 ? "SMALLINT" : "INTEGER";
285
295
  return [ret, ret];
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "@types/pg": "8.6.5",
10
10
  "pg": "8.7.3",
11
11
  "pg-format": "1.0.4",
12
- "sedentary": "0.0.33"
12
+ "sedentary": "0.0.36"
13
13
  },
14
14
  "description": "The ORM which never needs to migrate - PostgreSQL",
15
15
  "devDependencies": {
@@ -71,7 +71,7 @@
71
71
  "compilerOptions": {
72
72
  "alwaysStrict": true,
73
73
  "esModuleInterop": true,
74
- "moduleResolution": "node",
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": "esnext"
83
+ "target": "ESNext"
84
84
  }
85
85
  },
86
86
  "types": "./dist/types/index.d.ts",
87
- "version": "0.0.33"
87
+ "version": "0.0.36"
88
88
  }