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