@sqb/oracle 4.20.2 → 4.20.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/cjs/ora-adapter.js +24 -0
- package/esm/ora-adapter.js +24 -0
- package/package.json +4 -4
package/cjs/ora-adapter.js
CHANGED
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OraAdapter = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
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"));
|
|
6
9
|
const oracledb_1 = tslib_1.__importDefault(require("oracledb"));
|
|
7
10
|
const helpers_js_1 = require("./helpers.js");
|
|
8
11
|
const ora_connection_js_1 = require("./ora-connection.js");
|
|
@@ -15,6 +18,8 @@ class OraAdapter {
|
|
|
15
18
|
// fetchAsString: [DataType.DATE, DataType.TIMESTAMP, DataType.TIMESTAMPTZ]
|
|
16
19
|
};
|
|
17
20
|
async connect(config) {
|
|
21
|
+
if (!config.driverOptions?.direct)
|
|
22
|
+
initOracleClient();
|
|
18
23
|
const cfg = (0, helpers_js_1.clientConfigurationToDriver)(config);
|
|
19
24
|
// Get oracle connection
|
|
20
25
|
const connection = await oracledb_1.default.getConnection(cfg);
|
|
@@ -38,3 +43,22 @@ class OraAdapter {
|
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
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/esm/ora-adapter.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import '@sqb/oracle-dialect';
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import * as os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
2
5
|
import oracledb from 'oracledb';
|
|
3
6
|
import { clientConfigurationToDriver } from './helpers.js';
|
|
4
7
|
import { OraConnection } from './ora-connection.js';
|
|
@@ -11,6 +14,8 @@ export class OraAdapter {
|
|
|
11
14
|
// fetchAsString: [DataType.DATE, DataType.TIMESTAMP, DataType.TIMESTAMPTZ]
|
|
12
15
|
};
|
|
13
16
|
async connect(config) {
|
|
17
|
+
if (!config.driverOptions?.direct)
|
|
18
|
+
initOracleClient();
|
|
14
19
|
const cfg = clientConfigurationToDriver(config);
|
|
15
20
|
// Get oracle connection
|
|
16
21
|
const connection = await oracledb.getConnection(cfg);
|
|
@@ -33,3 +38,22 @@ export class OraAdapter {
|
|
|
33
38
|
}
|
|
34
39
|
}
|
|
35
40
|
}
|
|
41
|
+
let oracleClientInitialized = false;
|
|
42
|
+
function initOracleClient() {
|
|
43
|
+
if (oracleClientInitialized)
|
|
44
|
+
return;
|
|
45
|
+
const libDirs = process.env.LD_LIBRARY_PATH || process.env.ORA_HOME;
|
|
46
|
+
if (libDirs) {
|
|
47
|
+
for (const libDir of libDirs.split(':')) {
|
|
48
|
+
if ((os.type() === 'Linux' &&
|
|
49
|
+
fs.existsSync(path.join(libDir, 'libclntsh.so'))) ||
|
|
50
|
+
(os.type() === 'Darwin' &&
|
|
51
|
+
fs.existsSync(path.join(libDir, 'libclntsh.dylib'))) ||
|
|
52
|
+
(os.type() === 'Windows_NT' &&
|
|
53
|
+
fs.existsSync(path.join(libDir, 'oci.dll')))) {
|
|
54
|
+
oracledb.initOracleClient({ libDir });
|
|
55
|
+
oracleClientInitialized = true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/oracle",
|
|
3
3
|
"description": "SQB serialization extension for Oracle database",
|
|
4
|
-
"version": "4.20.
|
|
4
|
+
"version": "4.20.3",
|
|
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.20.
|
|
12
|
-
"@sqb/connect": "^4.20.
|
|
13
|
-
"@sqb/oracle-dialect": "^4.20.
|
|
11
|
+
"@sqb/builder": "^4.20.3",
|
|
12
|
+
"@sqb/connect": "^4.20.3",
|
|
13
|
+
"@sqb/oracle-dialect": "^4.20.3",
|
|
14
14
|
"oracledb": ">= 6.4.0"
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|