@sqb/oracle 4.11.3 → 4.12.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/README.md CHANGED
@@ -18,12 +18,12 @@ SQB is an extensible, multi-dialect SQL query builder and Database connection wr
18
18
 
19
19
  ## Main goals
20
20
 
21
- - Single code base for any sql based database
22
- - Powerful and simplified query coding scheme
23
- - Fast applications with low memory requirements
24
- - Let applications work with large data tables efficiently
25
- - Support latest JavaScript language standards
26
- - Lightweight and extensible framework.
21
+ - Single code base for any sql based database
22
+ - Powerful and simplified query coding scheme
23
+ - Fast applications with low memory requirements
24
+ - Let applications work with large data tables efficiently
25
+ - Support latest JavaScript language standards
26
+ - Lightweight and extensible framework.
27
27
 
28
28
  You can report bugs and discuss features on the [GitHub issues](https://github.com/sqbjs/sqb/issues) page
29
29
 
@@ -39,40 +39,25 @@ $ npm install @sqb/oracle --save
39
39
 
40
40
  ## Node Compatibility
41
41
 
42
- - node >= 16.x
42
+ - node >= 16.x
43
43
 
44
44
  ### License
45
45
 
46
46
  SQB is available under [MIT](LICENSE) license.
47
47
 
48
48
  [npm-image]: https://img.shields.io/npm/v/@sqb/oracle.svg
49
-
50
49
  [npm-url]: https://npmjs.org/package/@sqb/oracle
51
-
52
50
  [travis-image]: https://img.shields.io/travis/sqbjs/@sqb/oracle/master.svg
53
-
54
51
  [travis-url]: https://travis-ci.org/sqbjs/@sqb/oracle
55
-
56
52
  [coveralls-image]: https://img.shields.io/coveralls/sqbjs/@sqb/oracle/master.svg
57
-
58
53
  [coveralls-url]: https://coveralls.io/r/sqbjs/@sqb/oracle
59
-
60
54
  [downloads-image]: https://img.shields.io/npm/dm/@sqb/oracle.svg
61
-
62
55
  [downloads-url]: https://npmjs.org/package/@sqb/oracle
63
-
64
56
  [gitter-image]: https://badges.gitter.im/sqbjs/@sqb/oracle.svg
65
-
66
57
  [gitter-url]: https://gitter.im/sqbjs/@sqb/oracle?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
67
-
68
58
  [dependencies-image]: https://david-dm.org/sqbjs/@sqb/oracle/status.svg
69
-
70
- [dependencies-url]:https://david-dm.org/sqbjs/@sqb/oracle
71
-
59
+ [dependencies-url]: https://david-dm.org/sqbjs/@sqb/oracle
72
60
  [devdependencies-image]: https://david-dm.org/sqbjs/@sqb/oracle/dev-status.svg
73
-
74
- [devdependencies-url]:https://david-dm.org/sqbjs/@sqb/oracle?type=dev
75
-
61
+ [devdependencies-url]: https://david-dm.org/sqbjs/@sqb/oracle?type=dev
76
62
  [quality-image]: http://npm.packagequality.com/shield/@sqb/oracle.png
77
-
78
63
  [quality-url]: http://packagequality.com/#?package=@sqb/oracle
package/cjs/helpers.js CHANGED
@@ -7,7 +7,7 @@ function clientConfigurationToDriver(config) {
7
7
  const cfg = {
8
8
  user: config.user,
9
9
  password: config.password,
10
- ...config.driverOptions
10
+ ...config.driverOptions,
11
11
  };
12
12
  if (config.host) {
13
13
  let hostUrl = config.host || 'localhost';
@@ -15,11 +15,9 @@ function clientConfigurationToDriver(config) {
15
15
  hostUrl = 'oracle://' + hostUrl;
16
16
  const parsed = url_1.default.parse(hostUrl, true);
17
17
  const host = decodeURI(parsed.hostname || '');
18
- const port = config.port ||
19
- (parsed.port && parseInt(parsed.port, 10)) || 1521;
20
- const database = config.database ||
21
- (parsed.pathname && decodeURI(parsed.pathname.substring(1)));
22
- cfg.connectString = `${host}:${port}${(database ? '/' + database : '')}`;
18
+ const port = config.port || (parsed.port && parseInt(parsed.port, 10)) || 1521;
19
+ const database = config.database || (parsed.pathname && decodeURI(parsed.pathname.substring(1)));
20
+ cfg.connectString = `${host}:${port}${database ? '/' + database : ''}`;
23
21
  if (!cfg.externalAuth) {
24
22
  if (parsed.auth) {
25
23
  const a = parsed.auth.split(':');
@@ -30,7 +30,7 @@ exports.dataTypeNames = {
30
30
  [oracledb_1.default.DB_TYPE_TIMESTAMP.name]: 'TIMESTAMP',
31
31
  [oracledb_1.default.DB_TYPE_TIMESTAMP_LTZ.name]: 'TIMESTAMP_LTZ',
32
32
  [oracledb_1.default.DB_TYPE_TIMESTAMP_TZ.name]: 'TIMESTAMP_TZ',
33
- [oracledb_1.default.DB_TYPE_VARCHAR.name]: 'VARCHAR'
33
+ [oracledb_1.default.DB_TYPE_VARCHAR.name]: 'VARCHAR',
34
34
  };
35
35
  const fetchTypeMap = {
36
36
  [oracledb_1.default.DB_TYPE_BFILE.name]: 'object',
@@ -57,7 +57,7 @@ const fetchTypeMap = {
57
57
  [oracledb_1.default.DB_TYPE_TIMESTAMP.name]: 'Date',
58
58
  [oracledb_1.default.DB_TYPE_TIMESTAMP_LTZ.name]: 'Date',
59
59
  [oracledb_1.default.DB_TYPE_TIMESTAMP_TZ.name]: 'Date',
60
- [oracledb_1.default.DB_TYPE_VARCHAR.name]: 'string'
60
+ [oracledb_1.default.DB_TYPE_VARCHAR.name]: 'string',
61
61
  };
62
62
  class OraConnection {
63
63
  constructor(conn, sessionId) {
@@ -96,7 +96,9 @@ class OraConnection {
96
96
  }
97
97
  async getSchema() {
98
98
  assert_1.default.ok(this.intlcon, 'DB session is closed');
99
- const r = await this.intlcon.execute('select sys_context( \'userenv\', \'current_schema\' ) from dual', [], { autoCommit: true });
99
+ const r = await this.intlcon.execute("select sys_context( 'userenv', 'current_schema' ) from dual", [], {
100
+ autoCommit: true,
101
+ });
100
102
  if (r && r.rows && r.rows[0])
101
103
  return r.rows[0][0];
102
104
  return '';
@@ -114,7 +116,7 @@ class OraConnection {
114
116
  const oraOptions = {
115
117
  autoCommit: request.autoCommit,
116
118
  resultSet: request.cursor,
117
- outFormat: request.objectRows ? oracledb_1.default.OUT_FORMAT_OBJECT : oracledb_1.default.OUT_FORMAT_ARRAY
119
+ outFormat: request.objectRows ? oracledb_1.default.OUT_FORMAT_OBJECT : oracledb_1.default.OUT_FORMAT_ARRAY,
118
120
  };
119
121
  if (request.cursor)
120
122
  oraOptions.fetchArraySize = request.fetchRows;
@@ -131,14 +133,13 @@ class OraConnection {
131
133
  const selectFields = request.returningFields.map(x => x.field + (x.alias ? ' as ' + x.alias : ''));
132
134
  let sql = `select ${selectFields.join(',')} from ${m[2]}\n`;
133
135
  if (m[1].toLowerCase() === 'insert into') {
134
- sql += 'where rowid=\'' + response.lastRowid + '\'';
136
+ sql += "where rowid='" + response.lastRowid + "'";
135
137
  response = await this.intlcon.execute(sql);
136
138
  }
137
- else
138
139
  // Emulate update ... returning
139
- if (m[1].toLowerCase() === 'update') {
140
+ else if (m[1].toLowerCase() === 'update') {
140
141
  const m2 = request.sql.match(/where (.+)/);
141
- sql += (m2 ? ' where ' + m2[1] : '');
142
+ sql += m2 ? ' where ' + m2[1] : '';
142
143
  response = await this.intlcon.execute(sql, request.params || [], oraOptions);
143
144
  }
144
145
  }
@@ -154,11 +155,12 @@ class OraConnection {
154
155
  rowNumberName = v.name;
155
156
  continue;
156
157
  }
158
+ const fetchType = typeof v.fetchType === 'object' ? v.fetchType.num : v.fetchType;
157
159
  const fieldInfo = {
158
160
  _inf: v,
159
161
  fieldName: v.name,
160
162
  dataType: v.dbTypeName || 'UNKNOWN',
161
- jsType: fetchTypeMap[v.fetchType || 2001]
163
+ jsType: fetchTypeMap[fetchType || 2001],
162
164
  };
163
165
  if (v.dbTypeName === 'CHAR')
164
166
  fieldInfo.fixedLength = true;
@@ -188,11 +190,11 @@ class OraConnection {
188
190
  }
189
191
  else if (response.resultSet) {
190
192
  out.rowType = request.objectRows ? 'object' : 'array';
191
- out.cursor =
192
- new ora_cursor_js_1.OraCursor(response.resultSet, {
193
- rowType: request.objectRows ? 'object' : 'array',
194
- rowNumberIdx, rowNumberName
195
- });
193
+ out.cursor = new ora_cursor_js_1.OraCursor(response.resultSet, {
194
+ rowType: request.objectRows ? 'object' : 'array',
195
+ rowNumberIdx,
196
+ rowNumberName,
197
+ });
196
198
  }
197
199
  return out;
198
200
  }
package/esm/helpers.js CHANGED
@@ -1,9 +1,9 @@
1
- import url from "url";
1
+ import url from 'url';
2
2
  export function clientConfigurationToDriver(config) {
3
3
  const cfg = {
4
4
  user: config.user,
5
5
  password: config.password,
6
- ...config.driverOptions
6
+ ...config.driverOptions,
7
7
  };
8
8
  if (config.host) {
9
9
  let hostUrl = config.host || 'localhost';
@@ -11,11 +11,9 @@ export function clientConfigurationToDriver(config) {
11
11
  hostUrl = 'oracle://' + hostUrl;
12
12
  const parsed = url.parse(hostUrl, true);
13
13
  const host = decodeURI(parsed.hostname || '');
14
- const port = config.port ||
15
- (parsed.port && parseInt(parsed.port, 10)) || 1521;
16
- const database = config.database ||
17
- (parsed.pathname && decodeURI(parsed.pathname.substring(1)));
18
- cfg.connectString = `${host}:${port}${(database ? '/' + database : '')}`;
14
+ const port = config.port || (parsed.port && parseInt(parsed.port, 10)) || 1521;
15
+ const database = config.database || (parsed.pathname && decodeURI(parsed.pathname.substring(1)));
16
+ cfg.connectString = `${host}:${port}${database ? '/' + database : ''}`;
19
17
  if (!cfg.externalAuth) {
20
18
  if (parsed.auth) {
21
19
  const a = parsed.auth.split(':');
@@ -26,7 +26,7 @@ export const dataTypeNames = {
26
26
  [oracledb.DB_TYPE_TIMESTAMP.name]: 'TIMESTAMP',
27
27
  [oracledb.DB_TYPE_TIMESTAMP_LTZ.name]: 'TIMESTAMP_LTZ',
28
28
  [oracledb.DB_TYPE_TIMESTAMP_TZ.name]: 'TIMESTAMP_TZ',
29
- [oracledb.DB_TYPE_VARCHAR.name]: 'VARCHAR'
29
+ [oracledb.DB_TYPE_VARCHAR.name]: 'VARCHAR',
30
30
  };
31
31
  const fetchTypeMap = {
32
32
  [oracledb.DB_TYPE_BFILE.name]: 'object',
@@ -53,7 +53,7 @@ const fetchTypeMap = {
53
53
  [oracledb.DB_TYPE_TIMESTAMP.name]: 'Date',
54
54
  [oracledb.DB_TYPE_TIMESTAMP_LTZ.name]: 'Date',
55
55
  [oracledb.DB_TYPE_TIMESTAMP_TZ.name]: 'Date',
56
- [oracledb.DB_TYPE_VARCHAR.name]: 'string'
56
+ [oracledb.DB_TYPE_VARCHAR.name]: 'string',
57
57
  };
58
58
  export class OraConnection {
59
59
  constructor(conn, sessionId) {
@@ -92,7 +92,9 @@ export class OraConnection {
92
92
  }
93
93
  async getSchema() {
94
94
  assert.ok(this.intlcon, 'DB session is closed');
95
- const r = await this.intlcon.execute('select sys_context( \'userenv\', \'current_schema\' ) from dual', [], { autoCommit: true });
95
+ const r = await this.intlcon.execute("select sys_context( 'userenv', 'current_schema' ) from dual", [], {
96
+ autoCommit: true,
97
+ });
96
98
  if (r && r.rows && r.rows[0])
97
99
  return r.rows[0][0];
98
100
  return '';
@@ -110,7 +112,7 @@ export class OraConnection {
110
112
  const oraOptions = {
111
113
  autoCommit: request.autoCommit,
112
114
  resultSet: request.cursor,
113
- outFormat: request.objectRows ? oracledb.OUT_FORMAT_OBJECT : oracledb.OUT_FORMAT_ARRAY
115
+ outFormat: request.objectRows ? oracledb.OUT_FORMAT_OBJECT : oracledb.OUT_FORMAT_ARRAY,
114
116
  };
115
117
  if (request.cursor)
116
118
  oraOptions.fetchArraySize = request.fetchRows;
@@ -127,14 +129,13 @@ export class OraConnection {
127
129
  const selectFields = request.returningFields.map(x => x.field + (x.alias ? ' as ' + x.alias : ''));
128
130
  let sql = `select ${selectFields.join(',')} from ${m[2]}\n`;
129
131
  if (m[1].toLowerCase() === 'insert into') {
130
- sql += 'where rowid=\'' + response.lastRowid + '\'';
132
+ sql += "where rowid='" + response.lastRowid + "'";
131
133
  response = await this.intlcon.execute(sql);
132
134
  }
133
- else
134
135
  // Emulate update ... returning
135
- if (m[1].toLowerCase() === 'update') {
136
+ else if (m[1].toLowerCase() === 'update') {
136
137
  const m2 = request.sql.match(/where (.+)/);
137
- sql += (m2 ? ' where ' + m2[1] : '');
138
+ sql += m2 ? ' where ' + m2[1] : '';
138
139
  response = await this.intlcon.execute(sql, request.params || [], oraOptions);
139
140
  }
140
141
  }
@@ -150,11 +151,12 @@ export class OraConnection {
150
151
  rowNumberName = v.name;
151
152
  continue;
152
153
  }
154
+ const fetchType = typeof v.fetchType === 'object' ? v.fetchType.num : v.fetchType;
153
155
  const fieldInfo = {
154
156
  _inf: v,
155
157
  fieldName: v.name,
156
158
  dataType: v.dbTypeName || 'UNKNOWN',
157
- jsType: fetchTypeMap[v.fetchType || 2001]
159
+ jsType: fetchTypeMap[fetchType || 2001],
158
160
  };
159
161
  if (v.dbTypeName === 'CHAR')
160
162
  fieldInfo.fixedLength = true;
@@ -184,11 +186,11 @@ export class OraConnection {
184
186
  }
185
187
  else if (response.resultSet) {
186
188
  out.rowType = request.objectRows ? 'object' : 'array';
187
- out.cursor =
188
- new OraCursor(response.resultSet, {
189
- rowType: request.objectRows ? 'object' : 'array',
190
- rowNumberIdx, rowNumberName
191
- });
189
+ out.cursor = new OraCursor(response.resultSet, {
190
+ rowType: request.objectRows ? 'object' : 'array',
191
+ rowNumberIdx,
192
+ rowNumberName,
193
+ });
192
194
  }
193
195
  return out;
194
196
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sqb/oracle",
3
3
  "description": "SQB serialization extension for Oracle database",
4
- "version": "4.11.3",
4
+ "version": "4.12.1",
5
5
  "author": "Panates",
6
6
  "contributors": [
7
7
  "Eray Hanoglu <e.hanoglu@panates.com>",
@@ -25,6 +25,8 @@
25
25
  "build:esm": "tsc -b tsconfig-build-esm.json",
26
26
  "postbuild": "cp README.md package.json ../../LICENSE ../../build/oracle && cp ../../package.cjs.json ../../build/oracle/cjs/package.json",
27
27
  "lint": "eslint . --max-warnings=0",
28
+ "lint:fix": "eslint . --max-warnings=0 --fix",
29
+ "format": "prettier . --write --log-level=warn",
28
30
  "test": "jest",
29
31
  "cover": "jest --collect-coverage",
30
32
  "clean": "npm run clean:src | npm run clean:dist | npm run clean:cover",
@@ -33,14 +35,14 @@
33
35
  "clean:cover": "rimraf ../../coverage/oracle"
34
36
  },
35
37
  "peerDependencies": {
36
- "@sqb/builder": "^4.11.3",
37
- "@sqb/connect": "^4.11.3",
38
- "@sqb/oracle-dialect": "^4.11.3",
38
+ "@sqb/builder": "^4.12.1",
39
+ "@sqb/connect": "^4.12.1",
40
+ "@sqb/oracle-dialect": "^4.12.1",
39
41
  "oracledb": ">= 6.4.0"
40
42
  },
41
43
  "devDependencies": {
42
- "@types/oracledb": "^6.3.0",
43
- "oracledb": "^6.4.0"
44
+ "@types/oracledb": "^6.5.1",
45
+ "oracledb": "^6.5.1"
44
46
  },
45
47
  "engines": {
46
48
  "node": ">=16.0",