@sqb/oracle 4.20.7 → 4.21.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/package.json +11 -27
- package/cjs/helpers.js +0 -33
- package/cjs/index.js +0 -6
- package/cjs/ora-adapter.js +0 -64
- package/cjs/ora-connection.js +0 -207
- package/cjs/ora-cursor.js +0 -58
- package/cjs/package.json +0 -3
- package/esm/package.json +0 -3
- package/types/index.d.cts +0 -1
- /package/{types/helpers.d.ts → helpers.d.ts} +0 -0
- /package/{esm/helpers.js → helpers.js} +0 -0
- /package/{types/index.d.ts → index.d.ts} +0 -0
- /package/{esm/index.js → index.js} +0 -0
- /package/{types/ora-adapter.d.ts → ora-adapter.d.ts} +0 -0
- /package/{esm/ora-adapter.js → ora-adapter.js} +0 -0
- /package/{types/ora-connection.d.ts → ora-connection.d.ts} +0 -0
- /package/{esm/ora-connection.js → ora-connection.js} +0 -0
- /package/{types/ora-cursor.d.ts → ora-cursor.d.ts} +0 -0
- /package/{esm/ora-cursor.js → ora-cursor.js} +0 -0
package/package.json
CHANGED
|
@@ -1,36 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/oracle",
|
|
3
3
|
"description": "SQB serialization extension for Oracle database",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.21.0",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"tslib": "^2.8.1"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
|
-
"@sqb/builder": "^4.
|
|
12
|
-
"@sqb/connect": "^4.
|
|
13
|
-
"@sqb/oracle-dialect": "^4.
|
|
11
|
+
"@sqb/builder": "^4.21.0",
|
|
12
|
+
"@sqb/connect": "^4.21.0",
|
|
13
|
+
"@sqb/oracle-dialect": "^4.21.0",
|
|
14
14
|
"oracledb": ">= 6.4.0"
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
|
+
"module": "./index.js",
|
|
18
|
+
"types": "./index.d.ts",
|
|
17
19
|
"exports": {
|
|
18
20
|
".": {
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
"default": "./esm/index.js"
|
|
22
|
-
},
|
|
23
|
-
"require": {
|
|
24
|
-
"types": "./types/index.d.cts",
|
|
25
|
-
"default": "./cjs/index.js"
|
|
26
|
-
},
|
|
27
|
-
"default": "./esm/index.js"
|
|
21
|
+
"types": "./index.d.ts",
|
|
22
|
+
"default": "./index.js"
|
|
28
23
|
},
|
|
29
24
|
"./package.json": "./package.json"
|
|
30
25
|
},
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=20.0"
|
|
28
|
+
},
|
|
34
29
|
"contributors": [
|
|
35
30
|
"Eray Hanoglu <e.hanoglu@panates.com>",
|
|
36
31
|
"Ilker Gurelli <i.gurelli@panates.com>"
|
|
@@ -40,17 +35,6 @@
|
|
|
40
35
|
"url": "https://github.com/panates/sqb.git",
|
|
41
36
|
"directory": "packages/oracle"
|
|
42
37
|
},
|
|
43
|
-
"engines": {
|
|
44
|
-
"node": ">=18.0"
|
|
45
|
-
},
|
|
46
|
-
"files": [
|
|
47
|
-
"bin/",
|
|
48
|
-
"cjs/",
|
|
49
|
-
"esm/",
|
|
50
|
-
"types/",
|
|
51
|
-
"LICENSE",
|
|
52
|
-
"README.md"
|
|
53
|
-
],
|
|
54
38
|
"keywords": [
|
|
55
39
|
"sqb",
|
|
56
40
|
"oracle",
|
package/cjs/helpers.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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) {
|
|
7
|
-
const cfg = {
|
|
8
|
-
user: config.user,
|
|
9
|
-
password: config.password,
|
|
10
|
-
...config.driverOptions,
|
|
11
|
-
};
|
|
12
|
-
if (config.host) {
|
|
13
|
-
let hostUrl = config.host || 'localhost';
|
|
14
|
-
if (!hostUrl.includes('://'))
|
|
15
|
-
hostUrl = 'oracle://' + hostUrl;
|
|
16
|
-
const parsed = url_1.default.parse(hostUrl, true);
|
|
17
|
-
const host = decodeURI(parsed.hostname || '');
|
|
18
|
-
const port = config.port || (parsed.port && parseInt(parsed.port, 10)) || 1521;
|
|
19
|
-
const database = config.database ||
|
|
20
|
-
(parsed.pathname && decodeURI(parsed.pathname.substring(1)));
|
|
21
|
-
cfg.connectString = `${host}:${port}${database ? '/' + database : ''}`;
|
|
22
|
-
if (!cfg.externalAuth) {
|
|
23
|
-
if (parsed.auth) {
|
|
24
|
-
const a = parsed.auth.split(':');
|
|
25
|
-
if (!cfg.user && a[0])
|
|
26
|
-
cfg.user = a[0];
|
|
27
|
-
if (!cfg.password && a[1])
|
|
28
|
-
cfg.password = a[1];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return cfg;
|
|
33
|
-
}
|
package/cjs/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
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/cjs/ora-adapter.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
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 fs = tslib_1.__importStar(require("node:fs"));
|
|
7
|
-
const os = tslib_1.__importStar(require("node:os"));
|
|
8
|
-
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
9
|
-
const oracledb_1 = tslib_1.__importDefault(require("oracledb"));
|
|
10
|
-
const helpers_js_1 = require("./helpers.js");
|
|
11
|
-
const ora_connection_js_1 = require("./ora-connection.js");
|
|
12
|
-
class OraAdapter {
|
|
13
|
-
driver = 'oracledb';
|
|
14
|
-
dialect = 'oracle';
|
|
15
|
-
features = {
|
|
16
|
-
cursor: true,
|
|
17
|
-
schema: true,
|
|
18
|
-
// fetchAsString: [DataType.DATE, DataType.TIMESTAMP, DataType.TIMESTAMPTZ]
|
|
19
|
-
};
|
|
20
|
-
async connect(config) {
|
|
21
|
-
if (!config.driverOptions?.direct)
|
|
22
|
-
initOracleClient();
|
|
23
|
-
const cfg = (0, helpers_js_1.clientConfigurationToDriver)(config);
|
|
24
|
-
// Get oracle connection
|
|
25
|
-
const connection = await oracledb_1.default.getConnection(cfg);
|
|
26
|
-
try {
|
|
27
|
-
/* Retrieve sessionId */
|
|
28
|
-
let sessionId;
|
|
29
|
-
const r = await connection.execute('select sid from v$mystat where rownum <= 1', [], {});
|
|
30
|
-
if (r && r.rows)
|
|
31
|
-
sessionId = r.rows[0][0];
|
|
32
|
-
const oracon = new ora_connection_js_1.OraConnection(connection, sessionId);
|
|
33
|
-
/* Set default schema */
|
|
34
|
-
if (config.schema)
|
|
35
|
-
await oracon.setSchema(config.schema);
|
|
36
|
-
return oracon;
|
|
37
|
-
}
|
|
38
|
-
catch (e) {
|
|
39
|
-
if (connection)
|
|
40
|
-
await connection.close();
|
|
41
|
-
throw e;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.OraAdapter = OraAdapter;
|
|
46
|
-
let oracleClientInitialized = false;
|
|
47
|
-
function initOracleClient() {
|
|
48
|
-
if (oracleClientInitialized)
|
|
49
|
-
return;
|
|
50
|
-
const libDirs = process.env.LD_LIBRARY_PATH || process.env.ORA_HOME;
|
|
51
|
-
if (libDirs) {
|
|
52
|
-
for (const libDir of libDirs.split(':')) {
|
|
53
|
-
if ((os.type() === 'Linux' &&
|
|
54
|
-
fs.existsSync(node_path_1.default.join(libDir, 'libclntsh.so'))) ||
|
|
55
|
-
(os.type() === 'Darwin' &&
|
|
56
|
-
fs.existsSync(node_path_1.default.join(libDir, 'libclntsh.dylib'))) ||
|
|
57
|
-
(os.type() === 'Windows_NT' &&
|
|
58
|
-
fs.existsSync(node_path_1.default.join(libDir, 'oci.dll')))) {
|
|
59
|
-
oracledb_1.default.initOracleClient({ libDir });
|
|
60
|
-
oracleClientInitialized = true;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
package/cjs/ora-connection.js
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
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',
|
|
34
|
-
};
|
|
35
|
-
const fetchTypeMap = {
|
|
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',
|
|
61
|
-
};
|
|
62
|
-
class OraConnection {
|
|
63
|
-
sessionId;
|
|
64
|
-
intlcon;
|
|
65
|
-
serverVersion;
|
|
66
|
-
_inTransaction = false;
|
|
67
|
-
constructor(conn, sessionId) {
|
|
68
|
-
this.sessionId = sessionId;
|
|
69
|
-
this.intlcon = conn;
|
|
70
|
-
this.serverVersion = '' + conn.oracleServerVersion;
|
|
71
|
-
}
|
|
72
|
-
async close() {
|
|
73
|
-
if (!this.intlcon)
|
|
74
|
-
return;
|
|
75
|
-
await this.intlcon.close();
|
|
76
|
-
this.intlcon = undefined;
|
|
77
|
-
}
|
|
78
|
-
async reset() {
|
|
79
|
-
return this.rollback();
|
|
80
|
-
}
|
|
81
|
-
async startTransaction() {
|
|
82
|
-
assert_1.default.ok(this.intlcon, 'Can not start transaction for a closed db session');
|
|
83
|
-
this._inTransaction = true;
|
|
84
|
-
}
|
|
85
|
-
async commit() {
|
|
86
|
-
assert_1.default.ok(this.intlcon, 'Can not commit transaction for a closed db session');
|
|
87
|
-
await this.intlcon.commit();
|
|
88
|
-
this._inTransaction = false;
|
|
89
|
-
}
|
|
90
|
-
async rollback() {
|
|
91
|
-
if (!this.intlcon)
|
|
92
|
-
return;
|
|
93
|
-
await this.intlcon.rollback();
|
|
94
|
-
this._inTransaction = false;
|
|
95
|
-
}
|
|
96
|
-
async test() {
|
|
97
|
-
assert_1.default.ok(this.intlcon, 'DB session is closed');
|
|
98
|
-
await this.intlcon.execute('select 1 from dual', [], {});
|
|
99
|
-
}
|
|
100
|
-
async getSchema() {
|
|
101
|
-
assert_1.default.ok(this.intlcon, 'DB session is closed');
|
|
102
|
-
const r = await this.intlcon.execute("select sys_context( 'userenv', 'current_schema' ) from dual", [], {
|
|
103
|
-
autoCommit: true,
|
|
104
|
-
});
|
|
105
|
-
if (r && r.rows && r.rows[0])
|
|
106
|
-
return r.rows[0][0];
|
|
107
|
-
return '';
|
|
108
|
-
}
|
|
109
|
-
async setSchema(schema) {
|
|
110
|
-
assert_1.default.ok(this.intlcon, 'Can not set schema of a closed db session');
|
|
111
|
-
await this.intlcon.execute('alter SESSION set CURRENT_SCHEMA = ' + schema, [], { autoCommit: true });
|
|
112
|
-
}
|
|
113
|
-
onGenerateQuery(prepared) {
|
|
114
|
-
prepared.dialect = 'oracle';
|
|
115
|
-
prepared.dialectVersion = this.serverVersion;
|
|
116
|
-
}
|
|
117
|
-
async execute(request) {
|
|
118
|
-
assert_1.default.ok(this.intlcon, 'Can not execute query with a closed db session');
|
|
119
|
-
const oraOptions = {
|
|
120
|
-
autoCommit: request.autoCommit,
|
|
121
|
-
resultSet: request.cursor,
|
|
122
|
-
outFormat: request.objectRows
|
|
123
|
-
? oracledb_1.default.OUT_FORMAT_OBJECT
|
|
124
|
-
: oracledb_1.default.OUT_FORMAT_ARRAY,
|
|
125
|
-
};
|
|
126
|
-
if (request.cursor)
|
|
127
|
-
oraOptions.fetchArraySize = request.fetchRows;
|
|
128
|
-
else
|
|
129
|
-
oraOptions.maxRows = request.fetchRows;
|
|
130
|
-
const out = {};
|
|
131
|
-
this.intlcon.action = request.action || '';
|
|
132
|
-
let response = await this.intlcon.execute(request.sql, request.params || [], oraOptions);
|
|
133
|
-
if (response.rowsAffected)
|
|
134
|
-
out.rowsAffected = response.rowsAffected;
|
|
135
|
-
if (out.rowsAffected === 1 && request.returningFields) {
|
|
136
|
-
const m = request.sql.match(/\b(insert into|update)\b ("?\w+\.?\w+"?)/i);
|
|
137
|
-
if (m) {
|
|
138
|
-
const selectFields = request.returningFields.map(x => x.field + (x.alias ? ' as ' + x.alias : ''));
|
|
139
|
-
let sql = `select ${selectFields.join(',')} from ${m[2]}\n`;
|
|
140
|
-
if (m[1].toLowerCase() === 'insert into') {
|
|
141
|
-
sql += "where rowid='" + response.lastRowid + "'";
|
|
142
|
-
response = await this.intlcon.execute(sql);
|
|
143
|
-
}
|
|
144
|
-
// Emulate update ... returning
|
|
145
|
-
else if (m[1].toLowerCase() === 'update') {
|
|
146
|
-
const m2 = request.sql.match(/where (.+)/);
|
|
147
|
-
sql += m2 ? ' where ' + m2[1] : '';
|
|
148
|
-
response = await this.intlcon.execute(sql, request.params || [], oraOptions);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
let fields;
|
|
153
|
-
let rowNumberIdx = -1;
|
|
154
|
-
let rowNumberName = '';
|
|
155
|
-
if (response.metaData) {
|
|
156
|
-
fields = out.fields = [];
|
|
157
|
-
for (const [idx, v] of response.metaData.entries()) {
|
|
158
|
-
if (v.name.toLowerCase() === 'row$number') {
|
|
159
|
-
rowNumberIdx = idx;
|
|
160
|
-
rowNumberName = v.name;
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
const fetchType = typeof v.fetchType === 'object' ? v.fetchType.num : v.fetchType;
|
|
164
|
-
const fieldInfo = {
|
|
165
|
-
_inf: v,
|
|
166
|
-
fieldName: v.name,
|
|
167
|
-
dataType: v.dbTypeName || 'UNKNOWN',
|
|
168
|
-
jsType: fetchTypeMap[fetchType || 2001],
|
|
169
|
-
};
|
|
170
|
-
if (v.dbTypeName === 'CHAR')
|
|
171
|
-
fieldInfo.fixedLength = true;
|
|
172
|
-
// others
|
|
173
|
-
if (v.byteSize)
|
|
174
|
-
fieldInfo.size = v.byteSize;
|
|
175
|
-
if (v.nullable)
|
|
176
|
-
fieldInfo.nullable = v.nullable;
|
|
177
|
-
if (v.precision)
|
|
178
|
-
fieldInfo.precision = v.precision;
|
|
179
|
-
fields.push(fieldInfo);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if (response.rows) {
|
|
183
|
-
out.rowType = request.objectRows ? 'object' : 'array';
|
|
184
|
-
out.rows = response.rows;
|
|
185
|
-
// remove row$number fields
|
|
186
|
-
if (out.rows && rowNumberIdx >= 0) {
|
|
187
|
-
for (const row of out.rows) {
|
|
188
|
-
if (Array.isArray(row))
|
|
189
|
-
row.splice(rowNumberIdx, 1);
|
|
190
|
-
else
|
|
191
|
-
delete row[rowNumberName];
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return out;
|
|
195
|
-
}
|
|
196
|
-
if (response.resultSet) {
|
|
197
|
-
out.rowType = request.objectRows ? 'object' : 'array';
|
|
198
|
-
out.cursor = new ora_cursor_js_1.OraCursor(response.resultSet, {
|
|
199
|
-
rowType: request.objectRows ? 'object' : 'array',
|
|
200
|
-
rowNumberIdx,
|
|
201
|
-
rowNumberName,
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
return out;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
exports.OraConnection = OraConnection;
|
package/cjs/ora-cursor.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OraCursor = void 0;
|
|
4
|
-
class OraCursor {
|
|
5
|
-
_resultSet;
|
|
6
|
-
_rowType;
|
|
7
|
-
_rowNumberIdx;
|
|
8
|
-
_rowNumberName;
|
|
9
|
-
constructor(resultSet, opts) {
|
|
10
|
-
this._rowType = opts.rowType;
|
|
11
|
-
this._resultSet = resultSet;
|
|
12
|
-
this._rowNumberIdx = opts.rowNumberIdx;
|
|
13
|
-
this._rowNumberName = opts.rowNumberName;
|
|
14
|
-
}
|
|
15
|
-
get isClosed() {
|
|
16
|
-
return !this._resultSet;
|
|
17
|
-
}
|
|
18
|
-
get rowType() {
|
|
19
|
-
return this._rowType;
|
|
20
|
-
}
|
|
21
|
-
async close() {
|
|
22
|
-
if (!this._resultSet)
|
|
23
|
-
return;
|
|
24
|
-
const resultSet = this._resultSet;
|
|
25
|
-
return new Promise((resolve, reject) => {
|
|
26
|
-
resultSet.close(err => {
|
|
27
|
-
if (err)
|
|
28
|
-
return reject(err);
|
|
29
|
-
this._resultSet = undefined;
|
|
30
|
-
resolve();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
fetch(nRows) {
|
|
35
|
-
return new Promise((resolve, reject) => {
|
|
36
|
-
if (!this._resultSet)
|
|
37
|
-
return resolve(undefined);
|
|
38
|
-
const resultSet = this._resultSet;
|
|
39
|
-
resultSet.getRows(nRows, (err, rows) => {
|
|
40
|
-
if (err)
|
|
41
|
-
return reject(err);
|
|
42
|
-
if (!(rows && rows.length))
|
|
43
|
-
return resolve(undefined);
|
|
44
|
-
/* remove row$number fields */
|
|
45
|
-
if (this._rowNumberName) {
|
|
46
|
-
for (const row of rows) {
|
|
47
|
-
if (Array.isArray(row))
|
|
48
|
-
row.splice(this._rowNumberIdx || 0, 1);
|
|
49
|
-
else
|
|
50
|
-
delete row[this._rowNumberName];
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
resolve(rows);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.OraCursor = OraCursor;
|
package/cjs/package.json
DELETED
package/esm/package.json
DELETED
package/types/index.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '@sqb/oracle-dialect';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|