@sqb/oracle 4.23.0 → 4.23.3

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 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
- ...omit(config.driverOptions, ['dateParamFormat']),
6
+ ...config.driverOptions,
8
7
  };
9
8
  if (config.host) {
10
9
  let hostUrl = config.host || 'localhost';
package/index.d.ts CHANGED
@@ -1 +1,4 @@
1
1
  import '@sqb/oracle-dialect';
2
+ export * from './constants.js';
3
+ export * from './ora-adapter.js';
4
+ export * from './ora-connection.js';
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 {
@@ -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
- dateParamFormat?: string;
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>;
@@ -45,6 +14,7 @@ export declare class OraConnection implements Adapter.Connection {
45
14
  test(): Promise<void>;
46
15
  getSchema(): Promise<string>;
47
16
  setSchema(schema: string): Promise<void>;
17
+ getInTransaction(): boolean;
48
18
  onGenerateQuery(prepared: QueryRequest): void;
49
19
  execute(request: QueryRequest): Promise<Adapter.Response>;
50
20
  }
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
- dateParamFormat;
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)
@@ -109,6 +53,9 @@ export class OraConnection {
109
53
  assert.ok(this.intlcon, 'Can not set schema of a closed db session');
110
54
  await this.intlcon.execute('alter SESSION set CURRENT_SCHEMA = ' + schema, [], { autoCommit: true });
111
55
  }
56
+ getInTransaction() {
57
+ return this._inTransaction;
58
+ }
112
59
  onGenerateQuery(prepared) {
113
60
  prepared.dialect = 'oracle';
114
61
  prepared.dialectVersion = this.serverVersion;
@@ -127,27 +74,6 @@ export class OraConnection {
127
74
  else
128
75
  oraOptions.maxRows = request.fetchRows;
129
76
  const out = {};
130
- const params = request.params;
131
- if (this.dateParamFormat) {
132
- const wrapDate = (v) => {
133
- if (v instanceof Date)
134
- return dateFns.format(v, this.dateParamFormat);
135
- if (v.value instanceof Date)
136
- v.value = dateFns.format(v.value, this.dateParamFormat);
137
- return v;
138
- };
139
- if (params && typeof params === 'object') {
140
- if (Array.isArray(params)) {
141
- params.forEach((v, i) => {
142
- params[i] = wrapDate(v);
143
- });
144
- }
145
- else
146
- Object.keys(params).forEach(k => {
147
- params[k] = wrapDate(params[k]);
148
- });
149
- }
150
- }
151
77
  this.intlcon.action = request.action || '';
152
78
  let response = await this.intlcon.execute(request.sql, request.params || [], oraOptions);
153
79
  if (response.rowsAffected)
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.0",
4
+ "version": "4.23.3",
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.0",
14
- "@sqb/connect": "^4.23.0",
15
- "@sqb/oracle-dialect": "^4.23.0",
11
+ "@sqb/builder": "^4.23.3",
12
+ "@sqb/connect": "^4.23.3",
13
+ "@sqb/oracle-dialect": "^4.23.3",
16
14
  "oracledb": ">= 6.4.0"
17
15
  },
18
16
  "type": "module",