@sqb/postgres 4.14.1 → 4.15.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/esm/datatype-map.js +30 -27
- package/esm/index.js +8 -5
- package/esm/pg-adapter.js +12 -8
- package/esm/pg-connection.js +26 -22
- package/package.json +25 -19
- package/cjs/package.json +0 -3
package/esm/datatype-map.js
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dataTypeToOID = dataTypeToOID;
|
|
4
|
+
const builder_1 = require("@sqb/builder");
|
|
5
|
+
const postgrejs_1 = require("postgrejs");
|
|
6
|
+
function dataTypeToOID(dataType, isArray) {
|
|
7
|
+
if (dataType === builder_1.DataType.DATE)
|
|
8
|
+
return isArray ? postgrejs_1.DataTypeOIDs._date : postgrejs_1.DataTypeOIDs.date;
|
|
9
|
+
if (dataType === builder_1.DataType.BOOL)
|
|
10
|
+
return isArray ? postgrejs_1.DataTypeOIDs._bool : postgrejs_1.DataTypeOIDs.bool;
|
|
11
|
+
if (dataType === builder_1.DataType.CHAR)
|
|
12
|
+
return isArray ? postgrejs_1.DataTypeOIDs._bpchar : postgrejs_1.DataTypeOIDs.bpchar;
|
|
13
|
+
if (dataType === builder_1.DataType.SMALLINT)
|
|
14
|
+
return isArray ? postgrejs_1.DataTypeOIDs._int2 : postgrejs_1.DataTypeOIDs.int2;
|
|
15
|
+
if (dataType === builder_1.DataType.INTEGER)
|
|
16
|
+
return isArray ? postgrejs_1.DataTypeOIDs._int4 : postgrejs_1.DataTypeOIDs.int4;
|
|
17
|
+
if (dataType === builder_1.DataType.BIGINT)
|
|
18
|
+
return isArray ? postgrejs_1.DataTypeOIDs._int8 : postgrejs_1.DataTypeOIDs.int8;
|
|
19
|
+
if (dataType === builder_1.DataType.BINARY)
|
|
20
|
+
return isArray ? postgrejs_1.DataTypeOIDs._bytea : postgrejs_1.DataTypeOIDs.bytea;
|
|
21
|
+
if (dataType === builder_1.DataType.FLOAT)
|
|
22
|
+
return isArray ? postgrejs_1.DataTypeOIDs._float4 : postgrejs_1.DataTypeOIDs.float4;
|
|
23
|
+
if (dataType === builder_1.DataType.DOUBLE)
|
|
24
|
+
return isArray ? postgrejs_1.DataTypeOIDs._float8 : postgrejs_1.DataTypeOIDs.float8;
|
|
25
|
+
if (dataType === builder_1.DataType.GUID)
|
|
26
|
+
return isArray ? postgrejs_1.DataTypeOIDs._uuid : postgrejs_1.DataTypeOIDs.uuid;
|
|
27
|
+
if (dataType === builder_1.DataType.TEXT)
|
|
28
|
+
return isArray ? postgrejs_1.DataTypeOIDs._text : postgrejs_1.DataTypeOIDs.text;
|
|
29
|
+
if (dataType === builder_1.DataType.JSON)
|
|
30
|
+
return isArray ? postgrejs_1.DataTypeOIDs._json : postgrejs_1.DataTypeOIDs.json;
|
|
28
31
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
require("@sqb/postgres-dialect");
|
|
5
|
+
const connect_1 = require("@sqb/connect");
|
|
6
|
+
const pg_adapter_js_1 = require("./pg-adapter.js");
|
|
7
|
+
connect_1.AdapterRegistry.register(new pg_adapter_js_1.PgAdapter());
|
|
8
|
+
tslib_1.__exportStar(require("./pg-adapter.js"), exports);
|
package/esm/pg-adapter.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PgAdapter = void 0;
|
|
4
|
+
require("@sqb/postgres-dialect");
|
|
5
|
+
const connect_1 = require("@sqb/connect");
|
|
6
|
+
const postgrejs_1 = require("postgrejs");
|
|
7
|
+
const pg_connection_js_1 = require("./pg-connection.js");
|
|
8
|
+
class PgAdapter {
|
|
6
9
|
constructor() {
|
|
7
10
|
this.driver = 'postgrejs';
|
|
8
11
|
this.dialect = 'postgres';
|
|
9
12
|
this.features = {
|
|
10
13
|
cursor: true,
|
|
11
14
|
schema: true,
|
|
12
|
-
fetchAsString: [DataType.DATE, DataType.TIMESTAMP, DataType.TIMESTAMPTZ],
|
|
15
|
+
fetchAsString: [connect_1.DataType.DATE, connect_1.DataType.TIMESTAMP, connect_1.DataType.TIMESTAMPTZ],
|
|
13
16
|
};
|
|
14
17
|
}
|
|
15
18
|
async connect(config) {
|
|
@@ -26,10 +29,10 @@ export class PgAdapter {
|
|
|
26
29
|
cfg.database = config.database;
|
|
27
30
|
if (config.schema)
|
|
28
31
|
cfg.schema = config.schema;
|
|
29
|
-
const connection = new Connection(cfg);
|
|
32
|
+
const connection = new postgrejs_1.Connection(cfg);
|
|
30
33
|
try {
|
|
31
34
|
await connection.connect();
|
|
32
|
-
return new PgConnection(connection);
|
|
35
|
+
return new pg_connection_js_1.PgConnection(connection);
|
|
33
36
|
}
|
|
34
37
|
catch (e) {
|
|
35
38
|
await connection.close(0);
|
|
@@ -37,3 +40,4 @@ export class PgAdapter {
|
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
}
|
|
43
|
+
exports.PgAdapter = PgAdapter;
|
package/esm/pg-connection.js
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PgConnection = void 0;
|
|
4
|
+
const connect_1 = require("@sqb/connect");
|
|
5
|
+
const postgrejs_1 = require("postgrejs");
|
|
6
|
+
const datatype_map_js_1 = require("./datatype-map.js");
|
|
4
7
|
const SqbDataTypToOIDMap = {
|
|
5
|
-
[DataType.BOOL]: DataTypeOIDs.bool,
|
|
6
|
-
[DataType.CHAR]: DataTypeOIDs.char,
|
|
7
|
-
[DataType.VARCHAR]: DataTypeOIDs.varchar,
|
|
8
|
-
[DataType.SMALLINT]: DataTypeOIDs.int2,
|
|
9
|
-
[DataType.INTEGER]: DataTypeOIDs.int4,
|
|
10
|
-
[DataType.BIGINT]: DataTypeOIDs.int8,
|
|
11
|
-
[DataType.FLOAT]: DataTypeOIDs.float4,
|
|
12
|
-
[DataType.DOUBLE]: DataTypeOIDs.float8,
|
|
13
|
-
[DataType.NUMBER]: DataTypeOIDs.float8,
|
|
14
|
-
[DataType.DATE]: DataTypeOIDs.date,
|
|
15
|
-
[DataType.TIMESTAMP]: DataTypeOIDs.timestamp,
|
|
16
|
-
[DataType.TIMESTAMPTZ]: DataTypeOIDs.timestamptz,
|
|
17
|
-
[DataType.TIME]: DataTypeOIDs.time,
|
|
18
|
-
[DataType.BINARY]: DataTypeOIDs.bytea,
|
|
19
|
-
[DataType.TEXT]: DataTypeOIDs.text,
|
|
20
|
-
[DataType.GUID]: DataTypeOIDs.uuid,
|
|
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,
|
|
21
24
|
};
|
|
22
|
-
|
|
25
|
+
class PgConnection {
|
|
23
26
|
constructor(conn) {
|
|
24
27
|
this.intlcon = conn;
|
|
25
28
|
}
|
|
@@ -98,9 +101,9 @@ export class PgConnection {
|
|
|
98
101
|
const params = query.params?.map((v, i) => {
|
|
99
102
|
const paramOpts = Array.isArray(query.paramOptions) ? query.paramOptions[i] : undefined;
|
|
100
103
|
if (v != null && paramOpts && paramOpts.dataType) {
|
|
101
|
-
const oid = dataTypeToOID(paramOpts.dataType, paramOpts.isArray);
|
|
104
|
+
const oid = (0, datatype_map_js_1.dataTypeToOID)(paramOpts.dataType, paramOpts.isArray);
|
|
102
105
|
if (oid)
|
|
103
|
-
return new BindParam(oid, v);
|
|
106
|
+
return new postgrejs_1.BindParam(oid, v);
|
|
104
107
|
}
|
|
105
108
|
return v;
|
|
106
109
|
});
|
|
@@ -152,3 +155,4 @@ export class PgConnection {
|
|
|
152
155
|
return result;
|
|
153
156
|
}
|
|
154
157
|
}
|
|
158
|
+
exports.PgConnection = PgConnection;
|
package/package.json
CHANGED
|
@@ -1,29 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/postgres",
|
|
3
3
|
"description": "SQB serialization extension for PostgreSQL database",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.15.0",
|
|
5
5
|
"author": "Panates",
|
|
6
|
-
"contributors": [
|
|
7
|
-
"Eray Hanoglu <e.hanoglu@panates.com>",
|
|
8
|
-
"Ilker Gurelli <i.gurelli@panates.com>"
|
|
9
|
-
],
|
|
10
6
|
"license": "Apache-2.0",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/sqbjs/sqb.git",
|
|
14
|
-
"directory": "packages/postgres"
|
|
15
|
-
},
|
|
16
|
-
"type": "module",
|
|
17
|
-
"module": "./esm/index.js",
|
|
18
|
-
"main": "./cjs/index.js",
|
|
19
|
-
"types": "./types/index.d.ts",
|
|
20
7
|
"scripts": {
|
|
21
8
|
"compile": "tsc",
|
|
22
9
|
"prebuild": "npm run lint && npm run clean",
|
|
23
10
|
"build": "npm run build:cjs && npm run build:esm",
|
|
24
11
|
"build:cjs": "tsc -b tsconfig-build-cjs.json",
|
|
25
12
|
"build:esm": "tsc -b tsconfig-build-esm.json",
|
|
26
|
-
"postbuild": "cp README.md package.json ../../LICENSE ../../build/postgres
|
|
13
|
+
"postbuild": "cp README.md package.json ../../LICENSE ../../build/postgres",
|
|
27
14
|
"lint": "eslint . --max-warnings=0",
|
|
28
15
|
"lint:fix": "eslint . --max-warnings=0 --fix",
|
|
29
16
|
"format": "prettier . --write --log-level=warn",
|
|
@@ -38,14 +25,33 @@
|
|
|
38
25
|
"putil-promisify": "^1.10.1"
|
|
39
26
|
},
|
|
40
27
|
"devDependencies": {
|
|
41
|
-
"postgrejs": "^2.
|
|
28
|
+
"postgrejs": "^2.16.0"
|
|
42
29
|
},
|
|
43
30
|
"peerDependencies": {
|
|
44
|
-
"@sqb/builder": "^4.
|
|
45
|
-
"@sqb/connect": "^4.
|
|
46
|
-
"@sqb/postgres-dialect": "^4.
|
|
31
|
+
"@sqb/builder": "^4.15.0",
|
|
32
|
+
"@sqb/connect": "^4.15.0",
|
|
33
|
+
"@sqb/postgres-dialect": "^4.15.0",
|
|
47
34
|
"postgrejs": ">=2.15.1 <3.0.0"
|
|
48
35
|
},
|
|
36
|
+
"main": "./cjs/index.js",
|
|
37
|
+
"module": "./esm/index.js",
|
|
38
|
+
"types": "./types/index.d.ts",
|
|
39
|
+
"exports": {
|
|
40
|
+
".": {
|
|
41
|
+
"require": "./cjs/index.js",
|
|
42
|
+
"import": "./esm/index.js",
|
|
43
|
+
"types": "./types/index.d.ts"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"contributors": [
|
|
47
|
+
"Eray Hanoglu <e.hanoglu@panates.com>",
|
|
48
|
+
"Ilker Gurelli <i.gurelli@panates.com>"
|
|
49
|
+
],
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "https://github.com/sqbjs/sqb.git",
|
|
53
|
+
"directory": "packages/postgres"
|
|
54
|
+
},
|
|
49
55
|
"engines": {
|
|
50
56
|
"node": ">=16.0",
|
|
51
57
|
"npm": ">=7.0.0"
|
package/cjs/package.json
DELETED