@sqb/oracle 4.23.0 → 4.23.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/constants.d.ts +54 -0
- package/constants.js +55 -0
- package/helpers.js +1 -2
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/ora-adapter.d.ts +0 -2
- package/ora-connection.d.ts +1 -32
- package/ora-connection.js +22 -76
- package/package.json +4 -6
package/constants.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export declare const dataTypeNames: {
|
|
2
|
+
DB_TYPE_BFILE: string;
|
|
3
|
+
DB_TYPE_BINARY_DOUBLE: string;
|
|
4
|
+
DB_TYPE_BINARY_FLOAT: string;
|
|
5
|
+
DB_TYPE_BINARY_INTEGER: string;
|
|
6
|
+
DB_TYPE_BLOB: string;
|
|
7
|
+
DB_TYPE_BOOLEAN: string;
|
|
8
|
+
DB_TYPE_CHAR: string;
|
|
9
|
+
DB_TYPE_CLOB: string;
|
|
10
|
+
DB_TYPE_CURSOR: string;
|
|
11
|
+
DB_TYPE_DATE: string;
|
|
12
|
+
DB_TYPE_INTERVAL_DS: string;
|
|
13
|
+
DB_TYPE_INTERVAL_YM: string;
|
|
14
|
+
DB_TYPE_LONG: string;
|
|
15
|
+
DB_TYPE_LONG_RAW: string;
|
|
16
|
+
DB_TYPE_NCHAR: string;
|
|
17
|
+
DB_TYPE_NCLOB: string;
|
|
18
|
+
DB_TYPE_NUMBER: string;
|
|
19
|
+
DB_TYPE_NVARCHAR: string;
|
|
20
|
+
DB_TYPE_OBJECT: string;
|
|
21
|
+
DB_TYPE_RAW: string;
|
|
22
|
+
DB_TYPE_ROWID: string;
|
|
23
|
+
DB_TYPE_TIMESTAMP: string;
|
|
24
|
+
DB_TYPE_TIMESTAMP_LTZ: string;
|
|
25
|
+
DB_TYPE_TIMESTAMP_TZ: string;
|
|
26
|
+
DB_TYPE_VARCHAR: string;
|
|
27
|
+
};
|
|
28
|
+
export declare const fetchTypeMap: {
|
|
29
|
+
DB_TYPE_BFILE: string;
|
|
30
|
+
DB_TYPE_BINARY_DOUBLE: string;
|
|
31
|
+
DB_TYPE_BINARY_FLOAT: string;
|
|
32
|
+
DB_TYPE_BINARY_INTEGER: string;
|
|
33
|
+
DB_TYPE_BLOB: string;
|
|
34
|
+
DB_TYPE_BOOLEAN: string;
|
|
35
|
+
DB_TYPE_CHAR: string;
|
|
36
|
+
DB_TYPE_CLOB: string;
|
|
37
|
+
DB_TYPE_CURSOR: string;
|
|
38
|
+
DB_TYPE_DATE: string;
|
|
39
|
+
DB_TYPE_INTERVAL_DS: string;
|
|
40
|
+
DB_TYPE_INTERVAL_YM: string;
|
|
41
|
+
DB_TYPE_LONG: string;
|
|
42
|
+
DB_TYPE_LONG_RAW: string;
|
|
43
|
+
DB_TYPE_NCHAR: string;
|
|
44
|
+
DB_TYPE_NCLOB: string;
|
|
45
|
+
DB_TYPE_NUMBER: string;
|
|
46
|
+
DB_TYPE_NVARCHAR: string;
|
|
47
|
+
DB_TYPE_OBJECT: string;
|
|
48
|
+
DB_TYPE_RAW: string;
|
|
49
|
+
DB_TYPE_ROWID: string;
|
|
50
|
+
DB_TYPE_TIMESTAMP: string;
|
|
51
|
+
DB_TYPE_TIMESTAMP_LTZ: string;
|
|
52
|
+
DB_TYPE_TIMESTAMP_TZ: string;
|
|
53
|
+
DB_TYPE_VARCHAR: string;
|
|
54
|
+
};
|
package/constants.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import oracledb from 'oracledb';
|
|
2
|
+
export const dataTypeNames = {
|
|
3
|
+
[oracledb.DB_TYPE_BFILE.name]: 'BFILE',
|
|
4
|
+
[oracledb.DB_TYPE_BINARY_DOUBLE.name]: 'BINARY_DOUBLE',
|
|
5
|
+
[oracledb.DB_TYPE_BINARY_FLOAT.name]: 'BINARY_FLOAT',
|
|
6
|
+
[oracledb.DB_TYPE_BINARY_INTEGER.name]: 'BINARY_INTEGER',
|
|
7
|
+
[oracledb.DB_TYPE_BLOB.name]: 'BLOB',
|
|
8
|
+
[oracledb.DB_TYPE_BOOLEAN.name]: 'BOOLEAN',
|
|
9
|
+
[oracledb.DB_TYPE_CHAR.name]: 'CHAR',
|
|
10
|
+
[oracledb.DB_TYPE_CLOB.name]: 'CLOB',
|
|
11
|
+
[oracledb.DB_TYPE_CURSOR.name]: 'CURSOR',
|
|
12
|
+
[oracledb.DB_TYPE_DATE.name]: 'DATE',
|
|
13
|
+
[oracledb.DB_TYPE_INTERVAL_DS.name]: 'INTERVAL_DS',
|
|
14
|
+
[oracledb.DB_TYPE_INTERVAL_YM.name]: 'INTERVAL_YM',
|
|
15
|
+
[oracledb.DB_TYPE_LONG.name]: 'LONG',
|
|
16
|
+
[oracledb.DB_TYPE_LONG_RAW.name]: 'LONG_RAW',
|
|
17
|
+
[oracledb.DB_TYPE_NCHAR.name]: 'NCHAR',
|
|
18
|
+
[oracledb.DB_TYPE_NCLOB.name]: 'NCLOB',
|
|
19
|
+
[oracledb.DB_TYPE_NUMBER.name]: 'NUMBER',
|
|
20
|
+
[oracledb.DB_TYPE_NVARCHAR.name]: 'NVARCHAR',
|
|
21
|
+
[oracledb.DB_TYPE_OBJECT.name]: 'OBJECT',
|
|
22
|
+
[oracledb.DB_TYPE_RAW.name]: 'RAW',
|
|
23
|
+
[oracledb.DB_TYPE_ROWID.name]: 'ROWID',
|
|
24
|
+
[oracledb.DB_TYPE_TIMESTAMP.name]: 'TIMESTAMP',
|
|
25
|
+
[oracledb.DB_TYPE_TIMESTAMP_LTZ.name]: 'TIMESTAMP_LTZ',
|
|
26
|
+
[oracledb.DB_TYPE_TIMESTAMP_TZ.name]: 'TIMESTAMP_TZ',
|
|
27
|
+
[oracledb.DB_TYPE_VARCHAR.name]: 'VARCHAR',
|
|
28
|
+
};
|
|
29
|
+
export const fetchTypeMap = {
|
|
30
|
+
[oracledb.DB_TYPE_BFILE.name]: 'object',
|
|
31
|
+
[oracledb.DB_TYPE_BINARY_DOUBLE.name]: 'number',
|
|
32
|
+
[oracledb.DB_TYPE_BINARY_FLOAT.name]: 'number',
|
|
33
|
+
[oracledb.DB_TYPE_BINARY_INTEGER.name]: 'number',
|
|
34
|
+
[oracledb.DB_TYPE_BLOB.name]: 'object',
|
|
35
|
+
[oracledb.DB_TYPE_BOOLEAN.name]: 'boolean',
|
|
36
|
+
[oracledb.DB_TYPE_CHAR.name]: 'string',
|
|
37
|
+
[oracledb.DB_TYPE_CLOB.name]: 'object',
|
|
38
|
+
[oracledb.DB_TYPE_CURSOR.name]: 'object',
|
|
39
|
+
[oracledb.DB_TYPE_DATE.name]: 'Date',
|
|
40
|
+
[oracledb.DB_TYPE_INTERVAL_DS.name]: 'string',
|
|
41
|
+
[oracledb.DB_TYPE_INTERVAL_YM.name]: 'string',
|
|
42
|
+
[oracledb.DB_TYPE_LONG.name]: 'number',
|
|
43
|
+
[oracledb.DB_TYPE_LONG_RAW.name]: 'Buffer',
|
|
44
|
+
[oracledb.DB_TYPE_NCHAR.name]: 'string',
|
|
45
|
+
[oracledb.DB_TYPE_NCLOB.name]: 'object',
|
|
46
|
+
[oracledb.DB_TYPE_NUMBER.name]: 'number',
|
|
47
|
+
[oracledb.DB_TYPE_NVARCHAR.name]: 'string',
|
|
48
|
+
[oracledb.DB_TYPE_OBJECT.name]: 'object',
|
|
49
|
+
[oracledb.DB_TYPE_RAW.name]: 'Buffer',
|
|
50
|
+
[oracledb.DB_TYPE_ROWID.name]: 'number',
|
|
51
|
+
[oracledb.DB_TYPE_TIMESTAMP.name]: 'Date',
|
|
52
|
+
[oracledb.DB_TYPE_TIMESTAMP_LTZ.name]: 'Date',
|
|
53
|
+
[oracledb.DB_TYPE_TIMESTAMP_TZ.name]: 'Date',
|
|
54
|
+
[oracledb.DB_TYPE_VARCHAR.name]: 'string',
|
|
55
|
+
};
|
package/helpers.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { omit } from '@jsopen/objects';
|
|
2
1
|
import url from 'url';
|
|
3
2
|
export function clientConfigurationToDriver(config) {
|
|
4
3
|
const cfg = {
|
|
5
4
|
user: config.user,
|
|
6
5
|
password: config.password,
|
|
7
|
-
...
|
|
6
|
+
...config.driverOptions,
|
|
8
7
|
};
|
|
9
8
|
if (config.host) {
|
|
10
9
|
let hostUrl = config.host || 'localhost';
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import '@sqb/oracle-dialect';
|
|
2
2
|
import { AdapterRegistry } from '@sqb/connect';
|
|
3
3
|
import { OraAdapter } from './ora-adapter.js';
|
|
4
|
+
export * from './constants.js';
|
|
5
|
+
export * from './ora-adapter.js';
|
|
6
|
+
export * from './ora-connection.js';
|
|
4
7
|
AdapterRegistry.register(new OraAdapter());
|
package/ora-adapter.d.ts
CHANGED
|
@@ -3,8 +3,6 @@ import type { Adapter, ClientConfiguration } from '@sqb/connect';
|
|
|
3
3
|
export interface OraClientConfiguration extends ClientConfiguration {
|
|
4
4
|
driverOptions?: {
|
|
5
5
|
direct?: boolean;
|
|
6
|
-
/** Format from date-fns. https://date-fns.org/ */
|
|
7
|
-
dateParamFormat?: string;
|
|
8
6
|
};
|
|
9
7
|
}
|
|
10
8
|
export declare class OraAdapter implements Adapter {
|
package/ora-connection.d.ts
CHANGED
|
@@ -1,42 +1,11 @@
|
|
|
1
1
|
import type { Adapter, QueryRequest } from '@sqb/connect';
|
|
2
2
|
import oracledb from 'oracledb';
|
|
3
|
-
export declare const dataTypeNames: {
|
|
4
|
-
DB_TYPE_BFILE: string;
|
|
5
|
-
DB_TYPE_BINARY_DOUBLE: string;
|
|
6
|
-
DB_TYPE_BINARY_FLOAT: string;
|
|
7
|
-
DB_TYPE_BINARY_INTEGER: string;
|
|
8
|
-
DB_TYPE_BLOB: string;
|
|
9
|
-
DB_TYPE_BOOLEAN: string;
|
|
10
|
-
DB_TYPE_CHAR: string;
|
|
11
|
-
DB_TYPE_CLOB: string;
|
|
12
|
-
DB_TYPE_CURSOR: string;
|
|
13
|
-
DB_TYPE_DATE: string;
|
|
14
|
-
DB_TYPE_INTERVAL_DS: string;
|
|
15
|
-
DB_TYPE_INTERVAL_YM: string;
|
|
16
|
-
DB_TYPE_LONG: string;
|
|
17
|
-
DB_TYPE_LONG_RAW: string;
|
|
18
|
-
DB_TYPE_NCHAR: string;
|
|
19
|
-
DB_TYPE_NCLOB: string;
|
|
20
|
-
DB_TYPE_NUMBER: string;
|
|
21
|
-
DB_TYPE_NVARCHAR: string;
|
|
22
|
-
DB_TYPE_OBJECT: string;
|
|
23
|
-
DB_TYPE_RAW: string;
|
|
24
|
-
DB_TYPE_ROWID: string;
|
|
25
|
-
DB_TYPE_TIMESTAMP: string;
|
|
26
|
-
DB_TYPE_TIMESTAMP_LTZ: string;
|
|
27
|
-
DB_TYPE_TIMESTAMP_TZ: string;
|
|
28
|
-
DB_TYPE_VARCHAR: string;
|
|
29
|
-
};
|
|
30
|
-
export interface OraConnectionOptions {
|
|
31
|
-
dateParamFormat?: string;
|
|
32
|
-
}
|
|
33
3
|
export declare class OraConnection implements Adapter.Connection {
|
|
34
4
|
sessionId: string;
|
|
35
5
|
private intlcon?;
|
|
36
6
|
serverVersion: string;
|
|
37
7
|
private _inTransaction;
|
|
38
|
-
|
|
39
|
-
constructor(conn: oracledb.Connection, sessionId: string, options?: OraConnectionOptions);
|
|
8
|
+
constructor(conn: oracledb.Connection, sessionId: string);
|
|
40
9
|
close(): Promise<void>;
|
|
41
10
|
reset(): Promise<void>;
|
|
42
11
|
startTransaction(): Promise<void>;
|
package/ora-connection.js
CHANGED
|
@@ -1,72 +1,16 @@
|
|
|
1
1
|
import assert from 'assert';
|
|
2
|
-
import * as dateFns from 'date-fns';
|
|
3
2
|
import oracledb from 'oracledb';
|
|
3
|
+
import { fetchTypeMap } from './constants.js';
|
|
4
4
|
import { OraCursor } from './ora-cursor.js';
|
|
5
|
-
export const dataTypeNames = {
|
|
6
|
-
[oracledb.DB_TYPE_BFILE.name]: 'BFILE',
|
|
7
|
-
[oracledb.DB_TYPE_BINARY_DOUBLE.name]: 'BINARY_DOUBLE',
|
|
8
|
-
[oracledb.DB_TYPE_BINARY_FLOAT.name]: 'BINARY_FLOAT',
|
|
9
|
-
[oracledb.DB_TYPE_BINARY_INTEGER.name]: 'BINARY_INTEGER',
|
|
10
|
-
[oracledb.DB_TYPE_BLOB.name]: 'BLOB',
|
|
11
|
-
[oracledb.DB_TYPE_BOOLEAN.name]: 'BOOLEAN',
|
|
12
|
-
[oracledb.DB_TYPE_CHAR.name]: 'CHAR',
|
|
13
|
-
[oracledb.DB_TYPE_CLOB.name]: 'CLOB',
|
|
14
|
-
[oracledb.DB_TYPE_CURSOR.name]: 'CURSOR',
|
|
15
|
-
[oracledb.DB_TYPE_DATE.name]: 'DATE',
|
|
16
|
-
[oracledb.DB_TYPE_INTERVAL_DS.name]: 'INTERVAL_DS',
|
|
17
|
-
[oracledb.DB_TYPE_INTERVAL_YM.name]: 'INTERVAL_YM',
|
|
18
|
-
[oracledb.DB_TYPE_LONG.name]: 'LONG',
|
|
19
|
-
[oracledb.DB_TYPE_LONG_RAW.name]: 'LONG_RAW',
|
|
20
|
-
[oracledb.DB_TYPE_NCHAR.name]: 'NCHAR',
|
|
21
|
-
[oracledb.DB_TYPE_NCLOB.name]: 'NCLOB',
|
|
22
|
-
[oracledb.DB_TYPE_NUMBER.name]: 'NUMBER',
|
|
23
|
-
[oracledb.DB_TYPE_NVARCHAR.name]: 'NVARCHAR',
|
|
24
|
-
[oracledb.DB_TYPE_OBJECT.name]: 'OBJECT',
|
|
25
|
-
[oracledb.DB_TYPE_RAW.name]: 'RAW',
|
|
26
|
-
[oracledb.DB_TYPE_ROWID.name]: 'ROWID',
|
|
27
|
-
[oracledb.DB_TYPE_TIMESTAMP.name]: 'TIMESTAMP',
|
|
28
|
-
[oracledb.DB_TYPE_TIMESTAMP_LTZ.name]: 'TIMESTAMP_LTZ',
|
|
29
|
-
[oracledb.DB_TYPE_TIMESTAMP_TZ.name]: 'TIMESTAMP_TZ',
|
|
30
|
-
[oracledb.DB_TYPE_VARCHAR.name]: 'VARCHAR',
|
|
31
|
-
};
|
|
32
|
-
const fetchTypeMap = {
|
|
33
|
-
[oracledb.DB_TYPE_BFILE.name]: 'object',
|
|
34
|
-
[oracledb.DB_TYPE_BINARY_DOUBLE.name]: 'number',
|
|
35
|
-
[oracledb.DB_TYPE_BINARY_FLOAT.name]: 'number',
|
|
36
|
-
[oracledb.DB_TYPE_BINARY_INTEGER.name]: 'number',
|
|
37
|
-
[oracledb.DB_TYPE_BLOB.name]: 'object',
|
|
38
|
-
[oracledb.DB_TYPE_BOOLEAN.name]: 'boolean',
|
|
39
|
-
[oracledb.DB_TYPE_CHAR.name]: 'string',
|
|
40
|
-
[oracledb.DB_TYPE_CLOB.name]: 'object',
|
|
41
|
-
[oracledb.DB_TYPE_CURSOR.name]: 'object',
|
|
42
|
-
[oracledb.DB_TYPE_DATE.name]: 'Date',
|
|
43
|
-
[oracledb.DB_TYPE_INTERVAL_DS.name]: 'string',
|
|
44
|
-
[oracledb.DB_TYPE_INTERVAL_YM.name]: 'string',
|
|
45
|
-
[oracledb.DB_TYPE_LONG.name]: 'number',
|
|
46
|
-
[oracledb.DB_TYPE_LONG_RAW.name]: 'Buffer',
|
|
47
|
-
[oracledb.DB_TYPE_NCHAR.name]: 'string',
|
|
48
|
-
[oracledb.DB_TYPE_NCLOB.name]: 'object',
|
|
49
|
-
[oracledb.DB_TYPE_NUMBER.name]: 'number',
|
|
50
|
-
[oracledb.DB_TYPE_NVARCHAR.name]: 'string',
|
|
51
|
-
[oracledb.DB_TYPE_OBJECT.name]: 'object',
|
|
52
|
-
[oracledb.DB_TYPE_RAW.name]: 'Buffer',
|
|
53
|
-
[oracledb.DB_TYPE_ROWID.name]: 'number',
|
|
54
|
-
[oracledb.DB_TYPE_TIMESTAMP.name]: 'Date',
|
|
55
|
-
[oracledb.DB_TYPE_TIMESTAMP_LTZ.name]: 'Date',
|
|
56
|
-
[oracledb.DB_TYPE_TIMESTAMP_TZ.name]: 'Date',
|
|
57
|
-
[oracledb.DB_TYPE_VARCHAR.name]: 'string',
|
|
58
|
-
};
|
|
59
5
|
export class OraConnection {
|
|
60
6
|
sessionId;
|
|
61
7
|
intlcon;
|
|
62
8
|
serverVersion;
|
|
63
9
|
_inTransaction = false;
|
|
64
|
-
|
|
65
|
-
constructor(conn, sessionId, options = {}) {
|
|
10
|
+
constructor(conn, sessionId) {
|
|
66
11
|
this.sessionId = sessionId;
|
|
67
12
|
this.intlcon = conn;
|
|
68
13
|
this.serverVersion = '' + conn.oracleServerVersion;
|
|
69
|
-
this.dateParamFormat = options.dateParamFormat;
|
|
70
14
|
}
|
|
71
15
|
async close() {
|
|
72
16
|
if (!this.intlcon)
|
|
@@ -128,25 +72,27 @@ export class OraConnection {
|
|
|
128
72
|
oraOptions.maxRows = request.fetchRows;
|
|
129
73
|
const out = {};
|
|
130
74
|
const params = request.params;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
params[k] = wrapDate(params[k]);
|
|
148
|
-
});
|
|
75
|
+
const wrapDate = (v) => {
|
|
76
|
+
if (v instanceof Date)
|
|
77
|
+
return {
|
|
78
|
+
type: oracledb.DB_TYPE_DATE,
|
|
79
|
+
dir: oracledb.BIND_IN,
|
|
80
|
+
value: v,
|
|
81
|
+
};
|
|
82
|
+
if (v.value instanceof Date)
|
|
83
|
+
v.type = oracledb.DB_TYPE_DATE;
|
|
84
|
+
return v;
|
|
85
|
+
};
|
|
86
|
+
if (params && typeof params === 'object') {
|
|
87
|
+
if (Array.isArray(params)) {
|
|
88
|
+
params.forEach((v, i) => {
|
|
89
|
+
params[i] = wrapDate(v);
|
|
90
|
+
});
|
|
149
91
|
}
|
|
92
|
+
else
|
|
93
|
+
Object.keys(params).forEach(k => {
|
|
94
|
+
params[k] = wrapDate(params[k]);
|
|
95
|
+
});
|
|
150
96
|
}
|
|
151
97
|
this.intlcon.action = request.action || '';
|
|
152
98
|
let response = await this.intlcon.execute(request.sql, request.params || [], oraOptions);
|
package/package.json
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/oracle",
|
|
3
3
|
"description": "SQB serialization extension for Oracle database",
|
|
4
|
-
"version": "4.23.
|
|
4
|
+
"version": "4.23.1",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"date-fns": "^4.1.0",
|
|
9
|
-
"@jsopen/objects": "^2.2.0",
|
|
10
8
|
"tslib": "^2.8.1"
|
|
11
9
|
},
|
|
12
10
|
"peerDependencies": {
|
|
13
|
-
"@sqb/builder": "^4.23.
|
|
14
|
-
"@sqb/connect": "^4.23.
|
|
15
|
-
"@sqb/oracle-dialect": "^4.23.
|
|
11
|
+
"@sqb/builder": "^4.23.1",
|
|
12
|
+
"@sqb/connect": "^4.23.1",
|
|
13
|
+
"@sqb/oracle-dialect": "^4.23.1",
|
|
16
14
|
"oracledb": ">= 6.4.0"
|
|
17
15
|
},
|
|
18
16
|
"type": "module",
|