@sqb/oracle 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/helpers.js +7 -3
- package/esm/index.js +6 -4
- package/esm/ora-adapter.js +13 -8
- package/esm/ora-connection.js +68 -63
- package/esm/ora-cursor.js +5 -1
- package/package.json +24 -18
- package/cjs/package.json +0 -3
package/esm/helpers.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clientConfigurationToDriver = clientConfigurationToDriver;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const url_1 = tslib_1.__importDefault(require("url"));
|
|
6
|
+
function clientConfigurationToDriver(config) {
|
|
3
7
|
const cfg = {
|
|
4
8
|
user: config.user,
|
|
5
9
|
password: config.password,
|
|
@@ -9,7 +13,7 @@ export function clientConfigurationToDriver(config) {
|
|
|
9
13
|
let hostUrl = config.host || 'localhost';
|
|
10
14
|
if (!hostUrl.includes('://'))
|
|
11
15
|
hostUrl = 'oracle://' + hostUrl;
|
|
12
|
-
const parsed =
|
|
16
|
+
const parsed = url_1.default.parse(hostUrl, true);
|
|
13
17
|
const host = decodeURI(parsed.hostname || '');
|
|
14
18
|
const port = config.port || (parsed.port && parseInt(parsed.port, 10)) || 1521;
|
|
15
19
|
const database = config.database || (parsed.pathname && decodeURI(parsed.pathname.substring(1)));
|
package/esm/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("@sqb/oracle-dialect");
|
|
4
|
+
const connect_1 = require("@sqb/connect");
|
|
5
|
+
const ora_adapter_js_1 = require("./ora-adapter.js");
|
|
6
|
+
connect_1.AdapterRegistry.register(new ora_adapter_js_1.OraAdapter());
|
package/esm/ora-adapter.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OraAdapter = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
require("@sqb/oracle-dialect");
|
|
6
|
+
const oracledb_1 = tslib_1.__importDefault(require("oracledb"));
|
|
7
|
+
const helpers_js_1 = require("./helpers.js");
|
|
8
|
+
const ora_connection_js_1 = require("./ora-connection.js");
|
|
9
|
+
class OraAdapter {
|
|
6
10
|
constructor() {
|
|
7
11
|
this.driver = 'oracledb';
|
|
8
12
|
this.dialect = 'oracle';
|
|
@@ -13,16 +17,16 @@ export class OraAdapter {
|
|
|
13
17
|
};
|
|
14
18
|
}
|
|
15
19
|
async connect(config) {
|
|
16
|
-
const cfg = clientConfigurationToDriver(config);
|
|
20
|
+
const cfg = (0, helpers_js_1.clientConfigurationToDriver)(config);
|
|
17
21
|
// Get oracle connection
|
|
18
|
-
const connection = await
|
|
22
|
+
const connection = await oracledb_1.default.getConnection(cfg);
|
|
19
23
|
try {
|
|
20
24
|
/* Retrieve sessionId */
|
|
21
25
|
let sessionId;
|
|
22
26
|
const r = await connection.execute('select sid from v$mystat where rownum <= 1', [], {});
|
|
23
27
|
if (r && r.rows)
|
|
24
28
|
sessionId = r.rows[0][0];
|
|
25
|
-
const oracon = new OraConnection(connection, sessionId);
|
|
29
|
+
const oracon = new ora_connection_js_1.OraConnection(connection, sessionId);
|
|
26
30
|
/* Set default schema */
|
|
27
31
|
if (config.schema)
|
|
28
32
|
await oracon.setSchema(config.schema);
|
|
@@ -35,3 +39,4 @@ export class OraAdapter {
|
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
41
|
}
|
|
42
|
+
exports.OraAdapter = OraAdapter;
|
package/esm/ora-connection.js
CHANGED
|
@@ -1,61 +1,65 @@
|
|
|
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
|
-
[
|
|
28
|
-
[
|
|
29
|
-
[
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OraConnection = exports.dataTypeNames = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
|
+
const oracledb_1 = tslib_1.__importDefault(require("oracledb"));
|
|
7
|
+
const ora_cursor_js_1 = require("./ora-cursor.js");
|
|
8
|
+
exports.dataTypeNames = {
|
|
9
|
+
[oracledb_1.default.DB_TYPE_BFILE.name]: 'BFILE',
|
|
10
|
+
[oracledb_1.default.DB_TYPE_BINARY_DOUBLE.name]: 'BINARY_DOUBLE',
|
|
11
|
+
[oracledb_1.default.DB_TYPE_BINARY_FLOAT.name]: 'BINARY_FLOAT',
|
|
12
|
+
[oracledb_1.default.DB_TYPE_BINARY_INTEGER.name]: 'BINARY_INTEGER',
|
|
13
|
+
[oracledb_1.default.DB_TYPE_BLOB.name]: 'BLOB',
|
|
14
|
+
[oracledb_1.default.DB_TYPE_BOOLEAN.name]: 'BOOLEAN',
|
|
15
|
+
[oracledb_1.default.DB_TYPE_CHAR.name]: 'CHAR',
|
|
16
|
+
[oracledb_1.default.DB_TYPE_CLOB.name]: 'CLOB',
|
|
17
|
+
[oracledb_1.default.DB_TYPE_CURSOR.name]: 'CURSOR',
|
|
18
|
+
[oracledb_1.default.DB_TYPE_DATE.name]: 'DATE',
|
|
19
|
+
[oracledb_1.default.DB_TYPE_INTERVAL_DS.name]: 'INTERVAL_DS',
|
|
20
|
+
[oracledb_1.default.DB_TYPE_INTERVAL_YM.name]: 'INTERVAL_YM',
|
|
21
|
+
[oracledb_1.default.DB_TYPE_LONG.name]: 'LONG',
|
|
22
|
+
[oracledb_1.default.DB_TYPE_LONG_RAW.name]: 'LONG_RAW',
|
|
23
|
+
[oracledb_1.default.DB_TYPE_NCHAR.name]: 'NCHAR',
|
|
24
|
+
[oracledb_1.default.DB_TYPE_NCLOB.name]: 'NCLOB',
|
|
25
|
+
[oracledb_1.default.DB_TYPE_NUMBER.name]: 'NUMBER',
|
|
26
|
+
[oracledb_1.default.DB_TYPE_NVARCHAR.name]: 'NVARCHAR',
|
|
27
|
+
[oracledb_1.default.DB_TYPE_OBJECT.name]: 'OBJECT',
|
|
28
|
+
[oracledb_1.default.DB_TYPE_RAW.name]: 'RAW',
|
|
29
|
+
[oracledb_1.default.DB_TYPE_ROWID.name]: 'ROWID',
|
|
30
|
+
[oracledb_1.default.DB_TYPE_TIMESTAMP.name]: 'TIMESTAMP',
|
|
31
|
+
[oracledb_1.default.DB_TYPE_TIMESTAMP_LTZ.name]: 'TIMESTAMP_LTZ',
|
|
32
|
+
[oracledb_1.default.DB_TYPE_TIMESTAMP_TZ.name]: 'TIMESTAMP_TZ',
|
|
33
|
+
[oracledb_1.default.DB_TYPE_VARCHAR.name]: 'VARCHAR',
|
|
30
34
|
};
|
|
31
35
|
const fetchTypeMap = {
|
|
32
|
-
[
|
|
33
|
-
[
|
|
34
|
-
[
|
|
35
|
-
[
|
|
36
|
-
[
|
|
37
|
-
[
|
|
38
|
-
[
|
|
39
|
-
[
|
|
40
|
-
[
|
|
41
|
-
[
|
|
42
|
-
[
|
|
43
|
-
[
|
|
44
|
-
[
|
|
45
|
-
[
|
|
46
|
-
[
|
|
47
|
-
[
|
|
48
|
-
[
|
|
49
|
-
[
|
|
50
|
-
[
|
|
51
|
-
[
|
|
52
|
-
[
|
|
53
|
-
[
|
|
54
|
-
[
|
|
55
|
-
[
|
|
56
|
-
[
|
|
36
|
+
[oracledb_1.default.DB_TYPE_BFILE.name]: 'object',
|
|
37
|
+
[oracledb_1.default.DB_TYPE_BINARY_DOUBLE.name]: 'number',
|
|
38
|
+
[oracledb_1.default.DB_TYPE_BINARY_FLOAT.name]: 'number',
|
|
39
|
+
[oracledb_1.default.DB_TYPE_BINARY_INTEGER.name]: 'number',
|
|
40
|
+
[oracledb_1.default.DB_TYPE_BLOB.name]: 'object',
|
|
41
|
+
[oracledb_1.default.DB_TYPE_BOOLEAN.name]: 'boolean',
|
|
42
|
+
[oracledb_1.default.DB_TYPE_CHAR.name]: 'string',
|
|
43
|
+
[oracledb_1.default.DB_TYPE_CLOB.name]: 'object',
|
|
44
|
+
[oracledb_1.default.DB_TYPE_CURSOR.name]: 'object',
|
|
45
|
+
[oracledb_1.default.DB_TYPE_DATE.name]: 'Date',
|
|
46
|
+
[oracledb_1.default.DB_TYPE_INTERVAL_DS.name]: 'string',
|
|
47
|
+
[oracledb_1.default.DB_TYPE_INTERVAL_YM.name]: 'string',
|
|
48
|
+
[oracledb_1.default.DB_TYPE_LONG.name]: 'number',
|
|
49
|
+
[oracledb_1.default.DB_TYPE_LONG_RAW.name]: 'Buffer',
|
|
50
|
+
[oracledb_1.default.DB_TYPE_NCHAR.name]: 'string',
|
|
51
|
+
[oracledb_1.default.DB_TYPE_NCLOB.name]: 'object',
|
|
52
|
+
[oracledb_1.default.DB_TYPE_NUMBER.name]: 'number',
|
|
53
|
+
[oracledb_1.default.DB_TYPE_NVARCHAR.name]: 'string',
|
|
54
|
+
[oracledb_1.default.DB_TYPE_OBJECT.name]: 'object',
|
|
55
|
+
[oracledb_1.default.DB_TYPE_RAW.name]: 'Buffer',
|
|
56
|
+
[oracledb_1.default.DB_TYPE_ROWID.name]: 'number',
|
|
57
|
+
[oracledb_1.default.DB_TYPE_TIMESTAMP.name]: 'Date',
|
|
58
|
+
[oracledb_1.default.DB_TYPE_TIMESTAMP_LTZ.name]: 'Date',
|
|
59
|
+
[oracledb_1.default.DB_TYPE_TIMESTAMP_TZ.name]: 'Date',
|
|
60
|
+
[oracledb_1.default.DB_TYPE_VARCHAR.name]: 'string',
|
|
57
61
|
};
|
|
58
|
-
|
|
62
|
+
class OraConnection {
|
|
59
63
|
constructor(conn, sessionId) {
|
|
60
64
|
this.sessionId = sessionId;
|
|
61
65
|
this._inTransaction = false;
|
|
@@ -72,11 +76,11 @@ export class OraConnection {
|
|
|
72
76
|
return this.rollback();
|
|
73
77
|
}
|
|
74
78
|
async startTransaction() {
|
|
75
|
-
|
|
79
|
+
assert_1.default.ok(this.intlcon, 'Can not start transaction for a closed db session');
|
|
76
80
|
this._inTransaction = true;
|
|
77
81
|
}
|
|
78
82
|
async commit() {
|
|
79
|
-
|
|
83
|
+
assert_1.default.ok(this.intlcon, 'Can not commit transaction for a closed db session');
|
|
80
84
|
await this.intlcon.commit();
|
|
81
85
|
this._inTransaction = false;
|
|
82
86
|
}
|
|
@@ -87,11 +91,11 @@ export class OraConnection {
|
|
|
87
91
|
this._inTransaction = false;
|
|
88
92
|
}
|
|
89
93
|
async test() {
|
|
90
|
-
|
|
94
|
+
assert_1.default.ok(this.intlcon, 'DB session is closed');
|
|
91
95
|
await this.intlcon.execute('select 1 from dual', [], {});
|
|
92
96
|
}
|
|
93
97
|
async getSchema() {
|
|
94
|
-
|
|
98
|
+
assert_1.default.ok(this.intlcon, 'DB session is closed');
|
|
95
99
|
const r = await this.intlcon.execute("select sys_context( 'userenv', 'current_schema' ) from dual", [], {
|
|
96
100
|
autoCommit: true,
|
|
97
101
|
});
|
|
@@ -100,7 +104,7 @@ export class OraConnection {
|
|
|
100
104
|
return '';
|
|
101
105
|
}
|
|
102
106
|
async setSchema(schema) {
|
|
103
|
-
|
|
107
|
+
assert_1.default.ok(this.intlcon, 'Can not set schema of a closed db session');
|
|
104
108
|
await this.intlcon.execute('alter SESSION set CURRENT_SCHEMA = ' + schema, [], { autoCommit: true });
|
|
105
109
|
}
|
|
106
110
|
onGenerateQuery(prepared) {
|
|
@@ -108,11 +112,11 @@ export class OraConnection {
|
|
|
108
112
|
prepared.dialectVersion = this.serverVersion;
|
|
109
113
|
}
|
|
110
114
|
async execute(request) {
|
|
111
|
-
|
|
115
|
+
assert_1.default.ok(this.intlcon, 'Can not execute query with a closed db session');
|
|
112
116
|
const oraOptions = {
|
|
113
117
|
autoCommit: request.autoCommit,
|
|
114
118
|
resultSet: request.cursor,
|
|
115
|
-
outFormat: request.objectRows ?
|
|
119
|
+
outFormat: request.objectRows ? oracledb_1.default.OUT_FORMAT_OBJECT : oracledb_1.default.OUT_FORMAT_ARRAY,
|
|
116
120
|
};
|
|
117
121
|
if (request.cursor)
|
|
118
122
|
oraOptions.fetchArraySize = request.fetchRows;
|
|
@@ -186,7 +190,7 @@ export class OraConnection {
|
|
|
186
190
|
}
|
|
187
191
|
if (response.resultSet) {
|
|
188
192
|
out.rowType = request.objectRows ? 'object' : 'array';
|
|
189
|
-
out.cursor = new OraCursor(response.resultSet, {
|
|
193
|
+
out.cursor = new ora_cursor_js_1.OraCursor(response.resultSet, {
|
|
190
194
|
rowType: request.objectRows ? 'object' : 'array',
|
|
191
195
|
rowNumberIdx,
|
|
192
196
|
rowNumberName,
|
|
@@ -195,3 +199,4 @@ export class OraConnection {
|
|
|
195
199
|
return out;
|
|
196
200
|
}
|
|
197
201
|
}
|
|
202
|
+
exports.OraConnection = OraConnection;
|
package/esm/ora-cursor.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OraCursor = void 0;
|
|
4
|
+
class OraCursor {
|
|
2
5
|
constructor(resultSet, opts) {
|
|
3
6
|
this._rowType = opts.rowType;
|
|
4
7
|
this._resultSet = resultSet;
|
|
@@ -48,3 +51,4 @@ export class OraCursor {
|
|
|
48
51
|
});
|
|
49
52
|
}
|
|
50
53
|
}
|
|
54
|
+
exports.OraCursor = OraCursor;
|
package/package.json
CHANGED
|
@@ -1,29 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/oracle",
|
|
3
3
|
"description": "SQB serialization extension for Oracle 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/oracle"
|
|
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/oracle
|
|
13
|
+
"postbuild": "cp README.md package.json ../../LICENSE ../../build/oracle",
|
|
27
14
|
"lint": "eslint . --max-warnings=0",
|
|
28
15
|
"lint:fix": "eslint . --max-warnings=0 --fix",
|
|
29
16
|
"format": "prettier . --write --log-level=warn",
|
|
@@ -35,15 +22,34 @@
|
|
|
35
22
|
"clean:cover": "rimraf ../../coverage/oracle"
|
|
36
23
|
},
|
|
37
24
|
"peerDependencies": {
|
|
38
|
-
"@sqb/builder": "^4.
|
|
39
|
-
"@sqb/connect": "^4.
|
|
40
|
-
"@sqb/oracle-dialect": "^4.
|
|
25
|
+
"@sqb/builder": "^4.15.0",
|
|
26
|
+
"@sqb/connect": "^4.15.0",
|
|
27
|
+
"@sqb/oracle-dialect": "^4.15.0",
|
|
41
28
|
"oracledb": ">= 6.4.0"
|
|
42
29
|
},
|
|
43
30
|
"devDependencies": {
|
|
44
31
|
"@types/oracledb": "^6.5.1",
|
|
45
32
|
"oracledb": "^6.6.0"
|
|
46
33
|
},
|
|
34
|
+
"main": "./cjs/index.js",
|
|
35
|
+
"module": "./esm/index.js",
|
|
36
|
+
"types": "./types/index.d.ts",
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"require": "./cjs/index.js",
|
|
40
|
+
"import": "./esm/index.js",
|
|
41
|
+
"types": "./types/index.d.ts"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"contributors": [
|
|
45
|
+
"Eray Hanoglu <e.hanoglu@panates.com>",
|
|
46
|
+
"Ilker Gurelli <i.gurelli@panates.com>"
|
|
47
|
+
],
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "https://github.com/sqbjs/sqb.git",
|
|
51
|
+
"directory": "packages/oracle"
|
|
52
|
+
},
|
|
47
53
|
"engines": {
|
|
48
54
|
"node": ">=16.0",
|
|
49
55
|
"npm": ">=7.0.0"
|
package/cjs/package.json
DELETED