oracledb 6.2.0 → 6.3.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.
Files changed (54) hide show
  1. package/README.md +2 -2
  2. package/build/Release/oracledb-6.3.0-darwin-x64.node +0 -0
  3. package/build/Release/oracledb-6.3.0-darwin-x64.node-buildinfo.txt +1 -0
  4. package/build/Release/oracledb-6.3.0-js-buildinfo.txt +1 -0
  5. package/build/Release/oracledb-6.3.0-linux-arm64.node +0 -0
  6. package/build/Release/oracledb-6.3.0-linux-arm64.node-buildinfo.txt +1 -0
  7. package/build/Release/oracledb-6.3.0-linux-x64.node +0 -0
  8. package/build/Release/oracledb-6.3.0-linux-x64.node-buildinfo.txt +1 -0
  9. package/build/Release/oracledb-6.3.0-win32-x64.node +0 -0
  10. package/build/Release/oracledb-6.3.0-win32-x64.node-buildinfo.txt +1 -0
  11. package/examples/README.md +26 -8
  12. package/examples/dbconfig.js +50 -26
  13. package/examples/example.js +6 -4
  14. package/lib/connection.js +66 -0
  15. package/lib/errors.js +18 -0
  16. package/lib/future.js +53 -0
  17. package/lib/impl/connection.js +56 -0
  18. package/lib/impl/pool.js +5 -3
  19. package/lib/impl/resultset.js +48 -11
  20. package/lib/oracledb.js +23 -8
  21. package/lib/pool.js +10 -0
  22. package/lib/thin/connection.js +46 -2
  23. package/lib/thin/dbObject.js +45 -1
  24. package/lib/thin/index.js +1 -1
  25. package/lib/thin/pool.js +3 -2
  26. package/lib/thin/protocol/buffer.js +15 -7
  27. package/lib/thin/protocol/capabilities.js +3 -1
  28. package/lib/thin/protocol/constants.js +31 -14
  29. package/lib/thin/protocol/messages/auth.js +6 -2
  30. package/lib/thin/protocol/messages/base.js +29 -14
  31. package/lib/thin/protocol/messages/dataType.js +8 -5
  32. package/lib/thin/protocol/messages/lobOp.js +7 -8
  33. package/lib/thin/protocol/messages/withData.js +53 -18
  34. package/lib/thin/protocol/utils.js +1 -1
  35. package/lib/thin/sqlnet/connStrategy.js +8 -4
  36. package/lib/thin/sqlnet/constants.js +138 -138
  37. package/lib/thin/sqlnet/navNodes.js +5 -5
  38. package/lib/thin/sqlnet/networkSession.js +9 -2
  39. package/lib/thin/sqlnet/ntTcp.js +7 -7
  40. package/lib/thin/statement.js +1 -1
  41. package/lib/thin/util.js +15 -4
  42. package/lib/types.js +6 -1
  43. package/lib/util.js +8 -0
  44. package/lib/version.js +1 -1
  45. package/package.json +1 -1
  46. package/build/Release/oracledb-6.2.0-darwin-x64.node +0 -0
  47. package/build/Release/oracledb-6.2.0-darwin-x64.node-buildinfo.txt +0 -1
  48. package/build/Release/oracledb-6.2.0-js-buildinfo.txt +0 -1
  49. package/build/Release/oracledb-6.2.0-linux-arm64.node +0 -0
  50. package/build/Release/oracledb-6.2.0-linux-arm64.node-buildinfo.txt +0 -1
  51. package/build/Release/oracledb-6.2.0-linux-x64.node +0 -0
  52. package/build/Release/oracledb-6.2.0-linux-x64.node-buildinfo.txt +0 -1
  53. package/build/Release/oracledb-6.2.0-win32-x64.node +0 -0
  54. package/build/Release/oracledb-6.2.0-win32-x64.node-buildinfo.txt +0 -1
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
- # node-oracledb version 6.2.0
1
+ # node-oracledb version 6.3.0
2
2
 
3
3
  The node-oracledb add-on for Node.js powers high performance Oracle Database
4
4
  applications. Applications can be written in TypeScript, or directly in
5
5
  JavaScript.
6
6
 
7
- Use node-oracledb 6.2.0 to connect Node.js 14.6, or later, to Oracle
7
+ Use node-oracledb 6.3.0 to connect Node.js 14.6, or later, to Oracle
8
8
  Database. Older versions of node-oracledb may work with older versions of
9
9
  Node.js.
10
10
 
@@ -0,0 +1 @@
1
+ oracledb-6.3.0-darwin-x64.node v18.16.0 6430a56e82b0405c4118fcc1060c3568be4c43aa 4b8ebc2af8c9d58f7260c9de81d220f14fcab777 Sun, 17 Dec 2023 09:33:07 GMT
@@ -0,0 +1 @@
1
+ 6430a56e82b0405c4118fcc1060c3568be4c43aa
@@ -0,0 +1 @@
1
+ oracledb-6.3.0-linux-arm64.node v16.20.2 6430a56e82b0405c4118fcc1060c3568be4c43aa 4b8ebc2af8c9d58f7260c9de81d220f14fcab777 Sun, 17 Dec 2023 09:47:35 GMT
@@ -0,0 +1 @@
1
+ oracledb-6.3.0-linux-x64.node v16.19.1 6430a56e82b0405c4118fcc1060c3568be4c43aa 4b8ebc2af8c9d58f7260c9de81d220f14fcab777 Fri, 15 Dec 2023 17:32:48 GMT
@@ -0,0 +1 @@
1
+ oracledb-6.3.0-win32-x64.node v14.17.3 6430a56e82b0405c4118fcc1060c3568be4c43aa 4b8ebc2af8c9d58f7260c9de81d220f14fcab777 Fri, 15 Dec 2023 17:43:19 GMT
@@ -1,8 +1,7 @@
1
1
  # Node-oracledb Examples
2
2
 
3
- The directory in node-oracledb's [Github repository](https://github.com/oracle/node-oracledb/tree/main/examples) contains a lot of [node-oracledb](https://www.npmjs.com/package/oracledb)
4
- examples. Documentation is
5
- [here](https://node-oracledb.readthedocs.io/en/latest/).
3
+ The directory in node-oracledb's [Github repository](https://github.com/oracle/node-oracledb/tree/main/examples) contains a lot of [node-oracledb](https://www.npmjs.com/package/oracledb) examples.
4
+ Documentation is [here](https://node-oracledb.readthedocs.io/en/latest/).
6
5
 
7
6
  To run the examples:
8
7
 
@@ -11,18 +10,37 @@ To run the examples:
11
10
  - Ensure that you navigate to the `examples` directory in your terminal window
12
11
  or IDE, where you are running the samples.
13
12
 
14
- - Review `dbconfig.js`. In your terminal window or IDE, set the environment
15
- variables. For example, set `NODE_ORACLEDB_PASSWORD` to the value of your
16
- database password.
13
+ - Review `dbconfig.js`.
17
14
 
18
- - Review the samples and then run them individually. For example, to see what
15
+ In your terminal window or IDE, set the following environment variables to
16
+ provide credentials for the `dbconfig.js` file.
17
+
18
+ - `NODE_ORACLEDB_USER` must be set to the database user.
19
+
20
+ - `NODE_ORACLEDB_PASSWORD` must be set to the database password.
21
+
22
+ - `NODE_ORACLEDB_CONNECTIONSTRING` must be set to the connection string that points to your database's location.
23
+
24
+ - `NODE_ORACLEDB_EXTERNALAUTH` provides the options for enabling external authentication. Setting this environment variable to "true" will enable external authentication. To ensure external authentication works, firstly make sure the Oracle external authentication service is correctly configured. See [Documentation for External Authentication](https://node-oracledb.readthedocs.io/en/latest/user_guide/connection_handling.html#extauth) for details.
25
+
26
+ - `NODE_ORACLEDB_DRIVER_MODE` provides an option to set the 'Thin' or 'Thick' modes of node-oracledb. Setting this environment variable to "thick" will enable Thick mode.
27
+ Setting it to "thin" will retain the Thin mode. The default mode is Thin.
28
+
29
+ - `NODE_ORACLEDB_WALLET_LOCATION` must be set to the local directory name for the wallets that may be required for mutual TLS (mTLS) connections, especially to Oracle Cloud
30
+ Autonomous Databases optionally. The wallet location can also be provided as a part of the database connect string.
31
+
32
+ - `NODE_ORACLEDB_WALLET_PASSWORD` must set to the password for the wallets that may be required for mutual TLS (mTLS) connections, especially to Oracle Cloud Autonomous Databases.
33
+
34
+ - `NODE_ORACLEDB_CLIENT_LIB_DIR` provides an optional path for the Oracle Client libraries to be used on Windows and macOS platforms, when using Thick mode in node-oracledb.
35
+
36
+ Review the examples and then run them individually. For example, to see what
19
37
  the file `example.js` does, use:
20
38
 
21
39
  ```
22
40
  node example.js
23
41
  ```
24
42
 
25
- - After running examples, the demonstration objects can be dropped with
43
+ After running the examples, the demonstration objects can be dropped with
26
44
  `demodrop.js`:
27
45
 
28
46
  ```
@@ -26,17 +26,16 @@
26
26
  * dbconfig.js
27
27
  *
28
28
  * DESCRIPTION
29
- * Holds the credentials used by node-oracledb examples to connect
30
- * to the database. Production applications should consider using
31
- * External Authentication to avoid hard coded credentials.
29
+ * Holds the credentials used by node-oracledb examples to connect to the
30
+ * database. Production applications should consider using External
31
+ * Authentication to avoid hard coded credentials.
32
32
  *
33
33
  * To create a database user, see
34
34
  * https://blogs.oracle.com/sql/post/how-to-create-users-grant-them-privileges-and-remove-them-in-oracle-database
35
35
  *
36
- * Applications can set the connectString value to an Easy Connect
37
- * string, or a Net Service Name from a tnsnames.ora file or
38
- * external naming service, or it can be the name of a local Oracle
39
- * database instance.
36
+ * Applications can set the connectString value to an Easy Connect string,
37
+ * or a Net Service Name from the tnsnames.ora file or an external naming
38
+ * service, or it can be the name of a local Oracle Database instance.
40
39
  *
41
40
  * If node-oracledb is linked with Instant Client, then an Easy
42
41
  * Connect string is generally appropriate. The basic syntax is:
@@ -50,20 +49,20 @@
50
49
  * refer to the latest Oracle documentation on Easy Connect syntax:
51
50
  * https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-B0437826-43C1-49EC-A94D-B650B6A4A6EE
52
51
  *
53
- * If using a tnsnames.ora file, the file can be in a default
54
- * location such as $ORACLE_HOME/network/admin/tnsnames.ora or
55
- * /etc/tnsnames.ora. Alternatively set the TNS_ADMIN environment
56
- * variable and put the file in $TNS_ADMIN/tnsnames.ora.
52
+ * If using a tnsnames.ora file, the file can be in a default location such
53
+ * as $ORACLE_HOME/network/admin/tnsnames.ora or /etc/tnsnames.ora.
54
+ * Alternatively set the TNS_ADMIN environment variable and put the file in
55
+ * $TNS_ADMIN/tnsnames.ora.
57
56
  *
58
- * If connectString is not specified, the empty string "" is used
59
- * which indicates to connect to the local, default database.
57
+ * If connectString is not specified, the empty string "" is used which
58
+ * indicates to connect to the local, default database.
60
59
  *
61
- * External Authentication can be used by setting the optional
62
- * property externalAuth to true. External Authentication allows
63
- * applications to use an external password store such as Oracle
64
- * Wallet so passwords do not need to be hard coded into the
65
- * application. The user and password properties for connecting or
66
- * creating a pool should not be set when externalAuth is true.
60
+ * External Authentication can be used by setting the optional property
61
+ * externalAuth to true. External Authentication allows applications to use
62
+ * an external password store such as Oracle Wallet, so that passwords
63
+ * do not need to be hard coded into the application. The user and password
64
+ * application. The user and password properties for connecting or creating
65
+ * a pool should not be set when externalAuth is true.
67
66
  *
68
67
  * TROUBLESHOOTING
69
68
  * Refer to the Error Handling section in node-oracledb documentation
@@ -73,21 +72,46 @@
73
72
  *
74
73
  *****************************************************************************/
75
74
 
76
- module.exports = {
77
- user : process.env.NODE_ORACLEDB_USER,
75
+ const config = {
76
+ user: process.env.NODE_ORACLEDB_USER,
78
77
 
79
78
  // Get the password from the environment variable
80
79
  // NODE_ORACLEDB_PASSWORD. The password could also be a hard coded
81
80
  // string (not recommended), or it could be prompted for.
82
- // Alternatively use External Authentication so that no password is
83
- // needed.
84
- password : process.env.NODE_ORACLEDB_PASSWORD,
81
+ // Alternatively use External Authentication so that no password is needed.
82
+ password: process.env.NODE_ORACLEDB_PASSWORD,
85
83
 
86
84
  // For information on connection strings see:
87
85
  // https://node-oracledb.readthedocs.io/en/latest/user_guide/connection_handling.html#connectionstrings
88
- connectString : process.env.NODE_ORACLEDB_CONNECTIONSTRING,
86
+ connectString: process.env.NODE_ORACLEDB_CONNECTIONSTRING,
89
87
 
90
88
  // Setting externalAuth is optional. It defaults to false. See:
91
89
  // https://node-oracledb.readthedocs.io/en/latest/user_guide/connection_handling.html#extauth
92
- externalAuth : process.env.NODE_ORACLEDB_EXTERNALAUTH ? true : false,
90
+ externalAuth: process.env.NODE_ORACLEDB_EXTERNALAUTH ? true : false,
93
91
  };
92
+
93
+ // Set the NODE_ORACLEDB_WALLET_LOCATION and NODE_ORACLEDB_WALLET_PASSWORD
94
+ // environment variables for database connections that require wallets.
95
+ // For example, creating and dropping a user.
96
+ // See the README.md file in this directory for more details.
97
+ if (process.env.NODE_ORACLEDB_WALLET_PASSWORD) {
98
+ config.walletPassword = process.env.NODE_ORACLEDB_WALLET_PASSWORD;
99
+ }
100
+
101
+ if (process.env.NODE_ORACLEDB_WALLET_LOCATION) {
102
+ config.walletLocation = process.env.NODE_ORACLEDB_WALLET_LOCATION;
103
+ }
104
+
105
+ // Set the NODE_ORACLEDB_DBA_USER and NODE_ORACLEDB_DBA_PASSWORD environment
106
+ // variables for database operations which require SYSDBA privileges.
107
+ // For example, creating and dropping a user. See the README.md file in this
108
+ // directory for more details.
109
+ if (process.env.NODE_ORACLEDB_DBA_USER) {
110
+ config.DBA_user = process.env.NODE_ORACLEDB_DBA_USER;
111
+ }
112
+
113
+ if (process.env.NODE_ORACLEDB_DBA_PASSWORD) {
114
+ config.DBA_password = process.env.NODE_ORACLEDB_DBA_PASSWORD;
115
+ }
116
+
117
+ module.exports = config;
@@ -54,14 +54,16 @@ if (process.env.NODE_ORACLEDB_DRIVER_MODE === 'thick') {
54
54
  // is not correct, you will get a DPI-1047 error. See the node-oracledb
55
55
  // installation documentation.
56
56
  let clientOpts = {};
57
- if (process.platform === 'win32') { // Windows
58
- clientOpts = { libDir: 'C:\\oracle\\instantclient_19_17' };
59
- } else if (process.platform === 'darwin' && process.arch === 'x64') { // macOS Intel
60
- clientOpts = { libDir: process.env.HOME + '/Downloads/instantclient_19_8' };
57
+ // On Windows and macOS Intel platforms, set the environment
58
+ // variable NODE_ORACLEDB_CLIENT_LIB_DIR to the Oracle Client library path
59
+ if (process.platform === 'win32' || (process.platform === 'darwin' && process.arch === 'x64')) {
60
+ clientOpts = { libDir: process.env.NODE_ORACLEDB_CLIENT_LIB_DIR };
61
61
  }
62
62
  oracledb.initOracleClient(clientOpts); // enable node-oracledb Thick mode
63
63
  }
64
64
 
65
+ console.log(oracledb.thin ? 'Running in thin mode' : 'Running in thick mode');
66
+
65
67
  async function run() {
66
68
  let connection;
67
69
 
package/lib/connection.js CHANGED
@@ -865,6 +865,11 @@ class Connection extends EventEmitter {
865
865
  throw err;
866
866
  }
867
867
 
868
+ // convert ORA errors to NJS
869
+ if (result.warning) {
870
+ result.warning = errors.transformErr(result.warning);
871
+ }
872
+
868
873
  // process queries; if a result set is not desired, fetch all of the rows
869
874
  // from the result set and then destroy the result set
870
875
  if (result.resultSet !== undefined) {
@@ -971,6 +976,24 @@ class Connection extends EventEmitter {
971
976
  this._impl.setExternalName(value);
972
977
  }
973
978
 
979
+ //---------------------------------------------------------------------------
980
+ // dbDomain (READONLY)
981
+ //
982
+ // Property for identifying the dbDomain of the Oracle Database.
983
+ //---------------------------------------------------------------------------
984
+ get dbDomain() {
985
+ return this._impl && this._impl.getDbDomain();
986
+ }
987
+
988
+ //---------------------------------------------------------------------------
989
+ // dbName (READONLY)
990
+ //
991
+ // Property for identifying the dbName of the Oracle Database.
992
+ //---------------------------------------------------------------------------
993
+ get dbName() {
994
+ return this._impl && this._impl.getDbName();
995
+ }
996
+
974
997
  //---------------------------------------------------------------------------
975
998
  // getDbObjectClass()
976
999
  //
@@ -1080,6 +1103,30 @@ class Connection extends EventEmitter {
1080
1103
  this._impl.isHealthy());
1081
1104
  }
1082
1105
 
1106
+ //---------------------------------------------------------------------------
1107
+ // maxOpenCursors
1108
+ //
1109
+ // Returns maximum number of cursors that can be opened in one session.
1110
+ //---------------------------------------------------------------------------
1111
+ get maxOpenCursors() {
1112
+ return this._impl && this._impl.getMaxOpenCursors();
1113
+ }
1114
+
1115
+ //---------------------------------------------------------------------------
1116
+ // warning
1117
+ //
1118
+ // Returns warningInfo.
1119
+ //---------------------------------------------------------------------------
1120
+ get warning() {
1121
+ let warning = this._impl.getWarning();
1122
+ if (warning) {
1123
+ // Make sure that warning code attribute is populated and ORA error
1124
+ // is converted to NJS, if required
1125
+ warning = errors.transformErr(warning);
1126
+ }
1127
+ return this._impl && warning;
1128
+ }
1129
+
1083
1130
  //---------------------------------------------------------------------------
1084
1131
  // module
1085
1132
  //
@@ -1117,6 +1164,25 @@ class Connection extends EventEmitter {
1117
1164
  return undefined;
1118
1165
  }
1119
1166
 
1167
+ //---------------------------------------------------------------------------
1168
+ // serviceName
1169
+ //
1170
+ // Returns the Oracle Database service name associated with the connection.
1171
+ //---------------------------------------------------------------------------
1172
+ get serviceName() {
1173
+ return this._impl && this._impl.getServiceName();
1174
+ }
1175
+
1176
+ //---------------------------------------------------------------------------
1177
+ // transactionInProgress
1178
+ //
1179
+ // Returns a boolean value based on the presence of an active transaction
1180
+ // on the connection
1181
+ //---------------------------------------------------------------------------
1182
+ get transactionInProgress() {
1183
+ return this._impl && this._impl.getTransactionInProgress();
1184
+ }
1185
+
1120
1186
  //---------------------------------------------------------------------------
1121
1187
  // ping()
1122
1188
  //
package/lib/errors.js CHANGED
@@ -136,6 +136,8 @@ const ERR_WRONG_VALUE_FOR_DBOBJECT_ELEM = 135;
136
136
  const ERR_WRONG_CRED_FOR_EXTAUTH = 136;
137
137
  const ERR_MISSING_BIND_VALUE = 137;
138
138
  const ERR_SERVER_VERSION_NOT_SUPPORTED = 138;
139
+ const ERR_UNEXPECTED_XML_TYPE = 139;
140
+ const ERR_WRONG_USER_FORMAT_EXTAUTH_PROXY = 140;
139
141
 
140
142
  // Oracle Net layer errors start from 500
141
143
  const ERR_CONNECTION_CLOSED = 500;
@@ -160,6 +162,9 @@ const ERR_INVALID_SID = 519;
160
162
  const ERR_TNS_NAMES_FILE_MISSING = 520;
161
163
  const ERR_CONNECTION_EOF = 521;
162
164
 
165
+ // Oracle SUCCESS_WITH_INFO warning start from 700
166
+ const WRN_COMPILATION_CREATE = 700;
167
+
163
168
  // define mapping for ODPI-C, OCI & ORA errors that need to be wrapped
164
169
  // with NJS errors
165
170
  const adjustErrorXref = new Map();
@@ -178,6 +183,7 @@ adjustErrorXref.set("ORA-00028", ERR_CONNECTION_CLOSED);
178
183
  adjustErrorXref.set("ORA-00600", ERR_CONNECTION_CLOSED);
179
184
  adjustErrorXref.set("ORA-24338", ERR_INVALID_REF_CURSOR);
180
185
  adjustErrorXref.set("ORA-25708", ERR_TOKEN_HAS_EXPIRED);
186
+ adjustErrorXref.set("ORA-24344", WRN_COMPILATION_CREATE);
181
187
 
182
188
  // define mapping for error messages
183
189
  const messages = new Map();
@@ -393,6 +399,10 @@ messages.set(ERR_MISSING_BIND_VALUE, // NJS-137
393
399
  'a bind variable replacement value for placeholder ":%s" was not provided');
394
400
  messages.set(ERR_SERVER_VERSION_NOT_SUPPORTED, // NJS-138
395
401
  'connections to this database server version are not supported by node-oracledb in Thin mode');
402
+ messages.set(ERR_UNEXPECTED_XML_TYPE, // NJS-139
403
+ 'unexpected XML type with flag %d');
404
+ messages.set(ERR_WRONG_USER_FORMAT_EXTAUTH_PROXY, // NJS-140
405
+ 'user name must be enclosed in [] when using external authentication with a proxy user');
396
406
 
397
407
  // Oracle Net layer errors
398
408
 
@@ -439,6 +449,11 @@ messages.set(ERR_TNS_NAMES_FILE_MISSING, // NJS-520
439
449
  messages.set(ERR_CONNECTION_EOF, // NJS-521
440
450
  'connection to host %s port %d received end-of-file on communication channel. (CONNECTION_ID=%s)');
441
451
 
452
+ // Oracle SUCCESS_WITH_INFO warning
453
+
454
+ messages.set(WRN_COMPILATION_CREATE, // NJS-700
455
+ 'creation succeeded with compilation errors');
456
+
442
457
  //-----------------------------------------------------------------------------
443
458
  // assert()
444
459
  //
@@ -772,7 +787,10 @@ module.exports = {
772
787
  ERR_WRONG_CRED_FOR_EXTAUTH,
773
788
  ERR_MISSING_BIND_VALUE,
774
789
  ERR_SERVER_VERSION_NOT_SUPPORTED,
790
+ ERR_UNEXPECTED_XML_TYPE,
791
+ ERR_WRONG_USER_FORMAT_EXTAUTH_PROXY,
775
792
  ERR_CONNECTION_CLOSED_CODE: `${ERR_PREFIX}-${ERR_CONNECTION_CLOSED}`,
793
+ WRN_COMPILATION_CREATE,
776
794
  assert,
777
795
  assertArgCount,
778
796
  assertParamPropBool,
package/lib/future.js ADDED
@@ -0,0 +1,53 @@
1
+ // Copyright (c) 2023, Oracle and/or its affiliates.
2
+
3
+ //-----------------------------------------------------------------------------
4
+ //
5
+ // This software is dual-licensed to you under the Universal Permissive License
6
+ // (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
7
+ // 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose
8
+ // either license.
9
+ //
10
+ // If you elect to accept the software under the Apache License, Version 2.0,
11
+ // the following applies:
12
+ //
13
+ // Licensed under the Apache License, Version 2.0 (the "License");
14
+ // you may not use this file except in compliance with the License.
15
+ // You may obtain a copy of the License at
16
+ //
17
+ // https://www.apache.org/licenses/LICENSE-2.0
18
+ //
19
+ // Unless required by applicable law or agreed to in writing, software
20
+ // distributed under the License is distributed on an "AS IS" BASIS,
21
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
+ // See the License for the specific language governing permissions and
23
+ // limitations under the License.
24
+ //
25
+ //-----------------------------------------------------------------------------
26
+
27
+ 'use strict';
28
+
29
+ const errors = require('./errors.js');
30
+
31
+ // future object used for managing backwards incompatible changes.
32
+ class Future {
33
+
34
+ constructor() {
35
+ this._featureFlags = {};
36
+ this._featureFlags.oldJsonColumnAsObj = false;
37
+ }
38
+
39
+ get oldJsonColumnAsObj() {
40
+ return this._featureFlags.oldJsonColumnAsObj;
41
+ }
42
+
43
+ // fetch VARCHAR2 and LOB columns that contain JSON data (and have
44
+ // the "IS JSON" constraint enabled) in the same way that columns
45
+ // of type JSON (which requires Oracle Database 21 and higher) are fetched.
46
+ set oldJsonColumnAsObj(value) {
47
+ errors.assertPropValue(typeof value === 'boolean', "oldJsonColumnAsObj");
48
+ this._featureFlags.oldJsonColumnAsObj = value;
49
+ }
50
+
51
+ }
52
+
53
+ module.exports = new Future;
@@ -208,6 +208,24 @@ class ConnectionImpl {
208
208
  errors.throwNotImplemented("getting current schema");
209
209
  }
210
210
 
211
+ //---------------------------------------------------------------------------
212
+ // getDbDomain()
213
+ //
214
+ // Returns the Oracle Database domain name associated with the connection.
215
+ //---------------------------------------------------------------------------
216
+ getDbDomain() {
217
+ errors.throwNotImplemented("getting db domain");
218
+ }
219
+
220
+ //---------------------------------------------------------------------------
221
+ // getDbName()
222
+ //
223
+ // Returns the Oracle Database name associated with the connection.
224
+ //---------------------------------------------------------------------------
225
+ getDbName() {
226
+ errors.throwNotImplemented("getting db name");
227
+ }
228
+
211
229
  //---------------------------------------------------------------------------
212
230
  // getDbObjectClass()
213
231
  //
@@ -244,6 +262,15 @@ class ConnectionImpl {
244
262
  errors.throwNotImplemented("getting the internal name");
245
263
  }
246
264
 
265
+ //---------------------------------------------------------------------------
266
+ // getMaxOpenCursors()
267
+ //
268
+ // Returns maximum number of cursors that can be opened in one session.
269
+ //---------------------------------------------------------------------------
270
+ getMaxOpenCursors() {
271
+ errors.throwNotImplemented("getting max open cursors");
272
+ }
273
+
247
274
  //---------------------------------------------------------------------------
248
275
  // getOracleServerVersion()
249
276
  //
@@ -271,6 +298,15 @@ class ConnectionImpl {
271
298
  errors.throwNotImplemented("getting a queue");
272
299
  }
273
300
 
301
+ //---------------------------------------------------------------------------
302
+ // getServiceName()
303
+ //
304
+ // Returns the Oracle Database service name associated with the connection.
305
+ //---------------------------------------------------------------------------
306
+ getServiceName() {
307
+ errors.throwNotImplemented("getting service name");
308
+ }
309
+
274
310
  //---------------------------------------------------------------------------
275
311
  // getSodaDatabase()
276
312
  //
@@ -307,6 +343,26 @@ class ConnectionImpl {
307
343
  errors.throwNotImplemented("getting the tag for the connection");
308
344
  }
309
345
 
346
+ //---------------------------------------------------------------------------
347
+ // getTransactionInProgress()
348
+ //
349
+ // Returns boolean based on the presence of an active transaction on the
350
+ // connection
351
+ //---------------------------------------------------------------------------
352
+ getTransactionInProgress() {
353
+ errors.throwNotImplemented("getting the status of an active transaction" +
354
+ " on the connection");
355
+ }
356
+
357
+ //---------------------------------------------------------------------------
358
+ // getWarning()
359
+ //
360
+ // Returns a warning on a connection
361
+ //---------------------------------------------------------------------------
362
+ getWarning() {
363
+ errors.throwNotImplemented("getting information about warning");
364
+ }
365
+
310
366
  //---------------------------------------------------------------------------
311
367
  // isHealthy()
312
368
  //
package/lib/impl/pool.js CHANGED
@@ -37,10 +37,10 @@ class PoolImpl {
37
37
  // Access token handler callback function which wraps the user callback and
38
38
  // returns the token to the implementation.
39
39
  //---------------------------------------------------------------------------
40
- async _accessTokenHandler(userFn, externalObj, refresh) {
40
+ async _accessTokenHandler(userFn, externalObj, refresh, accessTokenConfig) {
41
41
  let accessToken;
42
42
  try {
43
- let result = userFn(refresh);
43
+ let result = userFn(refresh, accessTokenConfig);
44
44
  if (result instanceof Promise) {
45
45
  result = await result;
46
46
  }
@@ -48,7 +48,9 @@ class PoolImpl {
48
48
  if (!nodbUtil.isTokenValid(result)) {
49
49
  errors.throwErr(errors.ERR_TOKEN_HAS_EXPIRED);
50
50
  }
51
-
51
+ if (typeof result === 'object' && result.privateKey !== undefined) {
52
+ result.privateKey = nodbUtil.denormalizePrivateKey(result.privateKey);
53
+ }
52
54
  accessToken = result;
53
55
  } finally {
54
56
  this.returnAccessToken(externalObj, accessToken);
@@ -30,7 +30,9 @@ const constants = require('../constants.js');
30
30
  const errors = require('../errors.js');
31
31
  const nodbUtil = require('../util.js');
32
32
  const settings = require('../settings.js');
33
+ const future = require('../future.js');
33
34
  const types = require('../types.js');
35
+ const Lob = require('../lob.js');
34
36
 
35
37
  // define implementation class
36
38
  class ResultSetImpl {
@@ -100,36 +102,71 @@ class ResultSetImpl {
100
102
  metadata.fetchType = actualFetchType;
101
103
  }
102
104
 
105
+ let converter;
106
+ const userConverter = metadata.converter;
107
+
108
+ // If IsJson is set convert to JSON objects unless
109
+ // user defined output type handler overwrites it.
110
+ if (future.oldJsonColumnAsObj && metadata.isJson && metadata.dbType !== types.DB_TYPE_JSON
111
+ && userConverter === undefined) {
112
+ const outConverter = async function(val) {
113
+ if (!val) {
114
+ return val;
115
+ }
116
+
117
+ let result = val;
118
+ if (val instanceof Lob) {
119
+ result = await val.getData();
120
+ }
121
+ if (result instanceof Buffer) {
122
+ result = result.toString();
123
+ }
124
+ result = JSON.parse(result);
125
+ return result;
126
+ };
127
+ converter = outConverter;
128
+ }
129
+
103
130
  // in thin mode, Oracle NUMBER values are internally fetched as string in
104
131
  // order to preserve precision so must be converted to JavaScript Number
105
132
  // when needed; other numeric and date types are fetched natively as
106
133
  // JavaScript Number and Date values and are converted to string using
107
134
  // toString() when desired
108
135
  if (settings.thin) {
109
- let converter;
110
- const userConverter = metadata.converter;
111
136
  if (metadata.dbType === types.DB_TYPE_NUMBER &&
112
- metadata.fetchType === types.DB_TYPE_NUMBER) {
137
+ metadata.fetchType === types.DB_TYPE_NUMBER) {
113
138
  converter = (v) => (v === null) ? null : parseFloat(v);
114
139
  } else if (metadata.fetchType === types.DB_TYPE_VARCHAR) {
115
140
  if (metadata.dbType === types.DB_TYPE_BINARY_DOUBLE ||
116
- metadata.dbType === types.DB_TYPE_BINARY_FLOAT ||
117
- metadata.dbType === types.DB_TYPE_DATE ||
118
- metadata.dbType === types.DB_TYPE_TIMESTAMP ||
119
- metadata.dbType === types.DB_TYPE_TIMESTAMP_LTZ ||
120
- metadata.dbType === types.DB_TYPE_TIMESTAMP_TZ) {
141
+ metadata.dbType === types.DB_TYPE_BINARY_FLOAT ||
142
+ metadata.dbType === types.DB_TYPE_DATE ||
143
+ metadata.dbType === types.DB_TYPE_TIMESTAMP ||
144
+ metadata.dbType === types.DB_TYPE_TIMESTAMP_LTZ ||
145
+ metadata.dbType === types.DB_TYPE_TIMESTAMP_TZ) {
121
146
  converter = (v) => (v === null) ? null : v.toString();
122
147
  } else if (metadata.dbType === types.DB_TYPE_RAW) {
123
148
  converter = (v) => (v === null) ? null : v.toString('hex').toUpperCase();
124
149
  }
150
+ } else if (metadata.dbType === types.DB_TYPE_XMLTYPE) {
151
+ const xmlConverter = async function(val) {
152
+ if (!val) {
153
+ return val;
154
+ }
155
+ if (typeof val === 'string') {
156
+ return val;
157
+ }
158
+ return await val.getData();
159
+ };
160
+ converter = xmlConverter;
125
161
  }
126
162
  if (userConverter && converter) {
127
163
  const internalConverter = converter;
128
164
  converter = (v) => userConverter(internalConverter(v));
129
165
  }
130
- if (converter) {
131
- metadata.converter = converter;
132
- }
166
+ }
167
+
168
+ if (converter) {
169
+ metadata.converter = converter;
133
170
  }
134
171
 
135
172
  }