@sqb/postgres 4.12.1 → 4.14.0
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/cjs/datatype-map.js +14 -15
- package/cjs/index.js +1 -1
- package/cjs/pg-adapter.js +3 -3
- package/cjs/pg-connection.js +18 -18
- package/esm/datatype-map.js +1 -1
- package/esm/index.js +2 -2
- package/esm/pg-adapter.js +2 -2
- package/esm/pg-connection.js +1 -1
- package/package.json +9 -8
- package/types/datatype-map.d.ts +1 -1
- package/types/pg-connection.d.ts +1 -1
package/cjs/datatype-map.js
CHANGED
|
@@ -1,32 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dataTypeToOID =
|
|
4
|
-
const postgresql_client_1 = require("postgresql-client");
|
|
3
|
+
exports.dataTypeToOID = dataTypeToOID;
|
|
5
4
|
const builder_1 = require("@sqb/builder");
|
|
5
|
+
const postgrejs_1 = require("postgrejs");
|
|
6
6
|
function dataTypeToOID(dataType, isArray) {
|
|
7
7
|
if (dataType === builder_1.DataType.DATE)
|
|
8
|
-
return isArray ?
|
|
8
|
+
return isArray ? postgrejs_1.DataTypeOIDs._date : postgrejs_1.DataTypeOIDs.date;
|
|
9
9
|
if (dataType === builder_1.DataType.BOOL)
|
|
10
|
-
return isArray ?
|
|
10
|
+
return isArray ? postgrejs_1.DataTypeOIDs._bool : postgrejs_1.DataTypeOIDs.bool;
|
|
11
11
|
if (dataType === builder_1.DataType.CHAR)
|
|
12
|
-
return isArray ?
|
|
12
|
+
return isArray ? postgrejs_1.DataTypeOIDs._bpchar : postgrejs_1.DataTypeOIDs.bpchar;
|
|
13
13
|
if (dataType === builder_1.DataType.SMALLINT)
|
|
14
|
-
return isArray ?
|
|
14
|
+
return isArray ? postgrejs_1.DataTypeOIDs._int2 : postgrejs_1.DataTypeOIDs.int2;
|
|
15
15
|
if (dataType === builder_1.DataType.INTEGER)
|
|
16
|
-
return isArray ?
|
|
16
|
+
return isArray ? postgrejs_1.DataTypeOIDs._int4 : postgrejs_1.DataTypeOIDs.int4;
|
|
17
17
|
if (dataType === builder_1.DataType.BIGINT)
|
|
18
|
-
return isArray ?
|
|
18
|
+
return isArray ? postgrejs_1.DataTypeOIDs._int8 : postgrejs_1.DataTypeOIDs.int8;
|
|
19
19
|
if (dataType === builder_1.DataType.BINARY)
|
|
20
|
-
return isArray ?
|
|
20
|
+
return isArray ? postgrejs_1.DataTypeOIDs._bytea : postgrejs_1.DataTypeOIDs.bytea;
|
|
21
21
|
if (dataType === builder_1.DataType.FLOAT)
|
|
22
|
-
return isArray ?
|
|
22
|
+
return isArray ? postgrejs_1.DataTypeOIDs._float4 : postgrejs_1.DataTypeOIDs.float4;
|
|
23
23
|
if (dataType === builder_1.DataType.DOUBLE)
|
|
24
|
-
return isArray ?
|
|
24
|
+
return isArray ? postgrejs_1.DataTypeOIDs._float8 : postgrejs_1.DataTypeOIDs.float8;
|
|
25
25
|
if (dataType === builder_1.DataType.GUID)
|
|
26
|
-
return isArray ?
|
|
26
|
+
return isArray ? postgrejs_1.DataTypeOIDs._uuid : postgrejs_1.DataTypeOIDs.uuid;
|
|
27
27
|
if (dataType === builder_1.DataType.TEXT)
|
|
28
|
-
return isArray ?
|
|
28
|
+
return isArray ? postgrejs_1.DataTypeOIDs._text : postgrejs_1.DataTypeOIDs.text;
|
|
29
29
|
if (dataType === builder_1.DataType.JSON)
|
|
30
|
-
return isArray ?
|
|
30
|
+
return isArray ? postgrejs_1.DataTypeOIDs._json : postgrejs_1.DataTypeOIDs.json;
|
|
31
31
|
}
|
|
32
|
-
exports.dataTypeToOID = dataTypeToOID;
|
package/cjs/index.js
CHANGED
|
@@ -4,5 +4,5 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
require("@sqb/postgres-dialect");
|
|
5
5
|
const connect_1 = require("@sqb/connect");
|
|
6
6
|
const pg_adapter_js_1 = require("./pg-adapter.js");
|
|
7
|
-
|
|
7
|
+
connect_1.AdapterRegistry.register(new pg_adapter_js_1.PgAdapter());
|
|
8
8
|
tslib_1.__exportStar(require("./pg-adapter.js"), exports);
|
package/cjs/pg-adapter.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PgAdapter = void 0;
|
|
4
4
|
require("@sqb/postgres-dialect");
|
|
5
|
-
const postgresql_client_1 = require("postgresql-client");
|
|
6
5
|
const connect_1 = require("@sqb/connect");
|
|
6
|
+
const postgrejs_1 = require("postgrejs");
|
|
7
7
|
const pg_connection_js_1 = require("./pg-connection.js");
|
|
8
8
|
class PgAdapter {
|
|
9
9
|
constructor() {
|
|
10
|
-
this.driver = '
|
|
10
|
+
this.driver = 'postgrejs';
|
|
11
11
|
this.dialect = 'postgres';
|
|
12
12
|
this.features = {
|
|
13
13
|
cursor: true,
|
|
@@ -29,7 +29,7 @@ class PgAdapter {
|
|
|
29
29
|
cfg.database = config.database;
|
|
30
30
|
if (config.schema)
|
|
31
31
|
cfg.schema = config.schema;
|
|
32
|
-
const connection = new
|
|
32
|
+
const connection = new postgrejs_1.Connection(cfg);
|
|
33
33
|
try {
|
|
34
34
|
await connection.connect();
|
|
35
35
|
return new pg_connection_js_1.PgConnection(connection);
|
package/cjs/pg-connection.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PgConnection = void 0;
|
|
4
|
-
const postgresql_client_1 = require("postgresql-client");
|
|
5
4
|
const connect_1 = require("@sqb/connect");
|
|
5
|
+
const postgrejs_1 = require("postgrejs");
|
|
6
6
|
const datatype_map_js_1 = require("./datatype-map.js");
|
|
7
7
|
const SqbDataTypToOIDMap = {
|
|
8
|
-
[connect_1.DataType.BOOL]:
|
|
9
|
-
[connect_1.DataType.CHAR]:
|
|
10
|
-
[connect_1.DataType.VARCHAR]:
|
|
11
|
-
[connect_1.DataType.SMALLINT]:
|
|
12
|
-
[connect_1.DataType.INTEGER]:
|
|
13
|
-
[connect_1.DataType.BIGINT]:
|
|
14
|
-
[connect_1.DataType.FLOAT]:
|
|
15
|
-
[connect_1.DataType.DOUBLE]:
|
|
16
|
-
[connect_1.DataType.NUMBER]:
|
|
17
|
-
[connect_1.DataType.DATE]:
|
|
18
|
-
[connect_1.DataType.TIMESTAMP]:
|
|
19
|
-
[connect_1.DataType.TIMESTAMPTZ]:
|
|
20
|
-
[connect_1.DataType.TIME]:
|
|
21
|
-
[connect_1.DataType.BINARY]:
|
|
22
|
-
[connect_1.DataType.TEXT]:
|
|
23
|
-
[connect_1.DataType.GUID]:
|
|
8
|
+
[connect_1.DataType.BOOL]: postgrejs_1.DataTypeOIDs.bool,
|
|
9
|
+
[connect_1.DataType.CHAR]: postgrejs_1.DataTypeOIDs.char,
|
|
10
|
+
[connect_1.DataType.VARCHAR]: postgrejs_1.DataTypeOIDs.varchar,
|
|
11
|
+
[connect_1.DataType.SMALLINT]: postgrejs_1.DataTypeOIDs.int2,
|
|
12
|
+
[connect_1.DataType.INTEGER]: postgrejs_1.DataTypeOIDs.int4,
|
|
13
|
+
[connect_1.DataType.BIGINT]: postgrejs_1.DataTypeOIDs.int8,
|
|
14
|
+
[connect_1.DataType.FLOAT]: postgrejs_1.DataTypeOIDs.float4,
|
|
15
|
+
[connect_1.DataType.DOUBLE]: postgrejs_1.DataTypeOIDs.float8,
|
|
16
|
+
[connect_1.DataType.NUMBER]: postgrejs_1.DataTypeOIDs.float8,
|
|
17
|
+
[connect_1.DataType.DATE]: postgrejs_1.DataTypeOIDs.date,
|
|
18
|
+
[connect_1.DataType.TIMESTAMP]: postgrejs_1.DataTypeOIDs.timestamp,
|
|
19
|
+
[connect_1.DataType.TIMESTAMPTZ]: postgrejs_1.DataTypeOIDs.timestamptz,
|
|
20
|
+
[connect_1.DataType.TIME]: postgrejs_1.DataTypeOIDs.time,
|
|
21
|
+
[connect_1.DataType.BINARY]: postgrejs_1.DataTypeOIDs.bytea,
|
|
22
|
+
[connect_1.DataType.TEXT]: postgrejs_1.DataTypeOIDs.text,
|
|
23
|
+
[connect_1.DataType.GUID]: postgrejs_1.DataTypeOIDs.uuid,
|
|
24
24
|
};
|
|
25
25
|
class PgConnection {
|
|
26
26
|
constructor(conn) {
|
|
@@ -103,7 +103,7 @@ class PgConnection {
|
|
|
103
103
|
if (v != null && paramOpts && paramOpts.dataType) {
|
|
104
104
|
const oid = (0, datatype_map_js_1.dataTypeToOID)(paramOpts.dataType, paramOpts.isArray);
|
|
105
105
|
if (oid)
|
|
106
|
-
return new
|
|
106
|
+
return new postgrejs_1.BindParam(oid, v);
|
|
107
107
|
}
|
|
108
108
|
return v;
|
|
109
109
|
});
|
package/esm/datatype-map.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DataTypeOIDs } from 'postgresql-client';
|
|
2
1
|
import { DataType } from '@sqb/builder';
|
|
2
|
+
import { DataTypeOIDs } from 'postgrejs';
|
|
3
3
|
export function dataTypeToOID(dataType, isArray) {
|
|
4
4
|
if (dataType === DataType.DATE)
|
|
5
5
|
return isArray ? DataTypeOIDs._date : DataTypeOIDs.date;
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '@sqb/postgres-dialect';
|
|
2
|
-
import {
|
|
2
|
+
import { AdapterRegistry } from '@sqb/connect';
|
|
3
3
|
import { PgAdapter } from './pg-adapter.js';
|
|
4
|
-
|
|
4
|
+
AdapterRegistry.register(new PgAdapter());
|
|
5
5
|
export * from './pg-adapter.js';
|
package/esm/pg-adapter.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import '@sqb/postgres-dialect';
|
|
2
|
-
import { Connection } from 'postgresql-client';
|
|
3
2
|
import { DataType } from '@sqb/connect';
|
|
3
|
+
import { Connection } from 'postgrejs';
|
|
4
4
|
import { PgConnection } from './pg-connection.js';
|
|
5
5
|
export class PgAdapter {
|
|
6
6
|
constructor() {
|
|
7
|
-
this.driver = '
|
|
7
|
+
this.driver = 'postgrejs';
|
|
8
8
|
this.dialect = 'postgres';
|
|
9
9
|
this.features = {
|
|
10
10
|
cursor: true,
|
package/esm/pg-connection.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BindParam, DataTypeOIDs } from 'postgresql-client';
|
|
2
1
|
import { DataType } from '@sqb/connect';
|
|
2
|
+
import { BindParam, DataTypeOIDs } from 'postgrejs';
|
|
3
3
|
import { dataTypeToOID } from './datatype-map.js';
|
|
4
4
|
const SqbDataTypToOIDMap = {
|
|
5
5
|
[DataType.BOOL]: DataTypeOIDs.bool,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/postgres",
|
|
3
3
|
"description": "SQB serialization extension for PostgreSQL database",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.14.0",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Eray Hanoglu <e.hanoglu@panates.com>",
|
|
@@ -25,25 +25,26 @@
|
|
|
25
25
|
"build:esm": "tsc -b tsconfig-build-esm.json",
|
|
26
26
|
"postbuild": "cp README.md package.json ../../LICENSE ../../build/postgres && cp ../../package.cjs.json ../../build/postgres/cjs/package.json",
|
|
27
27
|
"lint": "eslint . --max-warnings=0",
|
|
28
|
+
"lint:fix": "eslint . --max-warnings=0 --fix",
|
|
29
|
+
"format": "prettier . --write --log-level=warn",
|
|
28
30
|
"test": "jest",
|
|
29
31
|
"cover": "jest --collect-coverage",
|
|
30
32
|
"clean": "npm run clean:src | npm run clean:dist | npm run clean:cover",
|
|
31
33
|
"clean:src": "ts-cleanup -s src --all",
|
|
32
34
|
"clean:dist": "rimraf ../../build/postgres",
|
|
33
|
-
"clean:cover": "rimraf ../../coverage/postgres"
|
|
34
|
-
"format": "prettier . --write --log-level=warn"
|
|
35
|
+
"clean:cover": "rimraf ../../coverage/postgres"
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|
|
37
38
|
"putil-promisify": "^1.10.1"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
|
-
"
|
|
41
|
+
"postgrejs": "^2.15.1"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
43
|
-
"@sqb/builder": "^4.
|
|
44
|
-
"@sqb/connect": "^4.
|
|
45
|
-
"@sqb/postgres-dialect": "^4.
|
|
46
|
-
"
|
|
44
|
+
"@sqb/builder": "^4.14.0",
|
|
45
|
+
"@sqb/connect": "^4.14.0",
|
|
46
|
+
"@sqb/postgres-dialect": "^4.14.0",
|
|
47
|
+
"postgrejs": ">=2.15.1 <3.0.0"
|
|
47
48
|
},
|
|
48
49
|
"engines": {
|
|
49
50
|
"node": ">=16.0",
|
package/types/datatype-map.d.ts
CHANGED
package/types/pg-connection.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Connection, FieldInfo } from 'postgresql-client';
|
|
2
1
|
import { Adapter, QueryRequest } from '@sqb/connect';
|
|
2
|
+
import { Connection, FieldInfo } from 'postgrejs';
|
|
3
3
|
export declare class PgConnection implements Adapter.Connection {
|
|
4
4
|
private intlcon?;
|
|
5
5
|
constructor(conn: Connection);
|