Skip to content

Commit 94d28ce

Browse files
committed
6.1.0
1 parent 165cd42 commit 94d28ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+961
-504
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
# node-oracledb-prebuilt-for-lambda
22

33
- This module is forked from the currently un-maintained [node-oracledb-for-lambda](https://github.com/nalbion/node-oracledb-for-lambda).
4-
- Core oracledb libraries are derived from [node-oracledb](https://github.com/oracle/node-oracledb) v6.0.3
5-
- 6.0.3: Prebuilt for use with AWS Lambda nodejs18.x Runtime
4+
- Core oracledb libraries are derived from [node-oracledb](https://github.com/oracle/node-oracledb) v6.1.0
5+
- 6.1.0: Prebuilt for use with AWS Lambda nodejs18.x Runtime
66
- Also tested to work with AWS Lambda nodejs14.x, nodejs16.x, and nodejs18.x Runtime
77

88
The scripts to reproduce the build process can be found at [node-oracledb-lambda-test](https://github.com/romanbalayan/node-oracledb-lambda-test).
99

1010
# Usage
1111

1212
```bash
13-
npm install --save oracledb-prebuilt-for-lambda@6.0.3
13+
npm install --save oracledb-prebuilt-for-lambda@6.1.0
1414
```
1515

1616
# Versioning
1717
- Changed release version to match that of underlying node-oracledb version.
18-
- i.e. for release based on oracledb 6.0.3, release will be oracledb-prebuilt-for-lambda@6.0.3
18+
- i.e. for release based on oracledb 6.1.0, release will be oracledb-prebuilt-for-lambda@6.1.0
1919

2020

2121
# Releases
2222
| node-oracledb | oracledb-prebuilt-for-lambda |
2323
| ------------------- | ---------- |
24+
| 6.1.0 | 6.1.0 |
2425
| 6.0.3 | 6.0.3 |
2526
| 6.0.1 | 6.0.1 |
2627
| 5.5.0 | 5.5.0 |
@@ -35,6 +36,7 @@ npm install --save oracledb-prebuilt-for-lambda@6.0.3
3536

3637

3738
# Changelog
39+
- v6.1.0: [node-oracledb v6.1.0 changelog](https://node-oracledb.readthedocs.io/en/latest/release_notes.html#node-oracledb-v6-1-0-30-aug-2023)
3840
- v6.0.3: [node-oracledb v6.0.3 changelog](https://node-oracledb.readthedocs.io/en/latest/release_notes.html#node-oracledb-v6-0-3-12-jul-2023)
3941
- v6.0.1: [node-oracledb v6.0.1 changelog](https://node-oracledb.readthedocs.io/en/latest/release_notes.html#node-oracledb-v6-0-1-07-jun-2023)
4042
- v5.5.0: [node-oracledb v5.5.0 changelog](https://github.com/oracle/node-oracledb/blob/main/CHANGELOG.md#node-oracledb-v550-7-sep-2022)

build/Release/oracledb.node

4.55 KB
Binary file not shown.

lib/aqQueue.js

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@
2727
'use strict';
2828

2929
const { Buffer } = require('buffer');
30-
const constants = require('./constants.js');
3130
const errors = require('./errors.js');
3231
const nodbUtil = require('./util.js');
3332
const AqDeqOptions = require('./aqDeqOptions.js');
3433
const AqEnqOptions = require('./aqEnqOptions.js');
3534
const AqMessage = require('./aqMessage.js');
3635
const BaseDbObject = require('./dbObject.js');
36+
const transformer = require('./transformer.js');
37+
const types = require('./types.js');
3738

3839
class AqQueue {
3940

@@ -47,6 +48,19 @@ class AqQueue {
4748
value instanceof BaseDbObject);
4849
}
4950

51+
//---------------------------------------------------------------------------
52+
// _makeMessage()
53+
//
54+
// For enqOne()/deqOne()/enqMany()/deqMany(), wrap the return value with JS
55+
// layer object.
56+
//---------------------------------------------------------------------------
57+
_makeMessage(msgImpl) {
58+
const msg = new AqMessage();
59+
msg._impl = msgImpl;
60+
msg._payloadTypeClass = this._payloadTypeClass;
61+
return msg;
62+
}
63+
5064
//---------------------------------------------------------------------------
5165
// _verifyMessage()
5266
//
@@ -64,7 +78,7 @@ class AqQueue {
6478
message = {};
6579
} else {
6680
message = {...message};
67-
if (this._isPayload(message.payload)) {
81+
if (this._isJson || this._isPayload(message.payload)) {
6882
payload = message.payload;
6983
} else if (this._payloadTypeClass) {
7084
payload = new this._payloadTypeClass(message.payload);
@@ -74,7 +88,9 @@ class AqQueue {
7488
}
7589

7690
// validate payload
77-
if (typeof payload === 'string') {
91+
if (this._isJson) {
92+
message.payload = transformer.transformJsonValue(payload);
93+
} else if (typeof payload === 'string') {
7894
message.payload = Buffer.from(payload);
7995
} else if (Buffer.isBuffer(payload)) {
8096
message.payload = payload;
@@ -116,8 +132,17 @@ class AqQueue {
116132
// Creates the queue and populates some internal attributes.
117133
//---------------------------------------------------------------------------
118134
async create(conn, name, options) {
119-
if (options.payloadType) {
120-
if (typeof options.payloadType == 'string') {
135+
if (options.payloadType === types.DB_TYPE_JSON) {
136+
this._isJson = true;
137+
this._payloadType = types.DB_TYPE_JSON;
138+
this._payloadTypeName = "JSON";
139+
} else if (options.payloadType === undefined ||
140+
options.payloadType === types.DB_TYPE_RAW) {
141+
this._payloadType = types.DB_TYPE_RAW;
142+
this._payloadTypeName = "RAW";
143+
} else {
144+
if (typeof options.payloadType === 'string') {
145+
// DB Object type
121146
const cls = await conn._getDbObjectClassForName(options.payloadType);
122147
this._payloadTypeClass = cls;
123148
options.payloadType = cls;
@@ -126,14 +151,12 @@ class AqQueue {
126151
options.payloadType.prototype instanceof BaseDbObject, 2, "payloadType");
127152
this._payloadTypeClass = options.payloadType;
128153
}
129-
this._payloadType = constants.DB_TYPE_OBJECT;
154+
this._payloadType = types.DB_TYPE_OBJECT;
130155
this._payloadTypeName = this._payloadTypeClass.prototype.name;
131-
} else {
132-
this._payloadType = constants.DB_TYPE_RAW;
133-
this._payloadTypeName = "RAW";
134156
}
135157
this._name = name;
136-
this._impl = await conn._impl.getQueue(name, options);
158+
this._impl = await conn._impl.getQueue(name, this._payloadTypeClass,
159+
this._payloadType);
137160
}
138161

139162
//---------------------------------------------------------------------------
@@ -147,14 +170,7 @@ class AqQueue {
147170
errors.assertParamValue(Number.isInteger(maxMessages) && maxMessages > 0,
148171
1);
149172
const msgImpls = await this._impl.deqMany(maxMessages);
150-
const messages = new Array(msgImpls.length);
151-
for (let i = 0; i < msgImpls.length; i++) {
152-
const msg = new AqMessage();
153-
msg._impl = msgImpls[i];
154-
msg._payloadTypeClass = this._payloadTypeClass;
155-
messages[i] = msg;
156-
}
157-
return messages;
173+
return msgImpls.map(i => this._makeMessage(i));
158174
}
159175

160176
//---------------------------------------------------------------------------
@@ -165,12 +181,8 @@ class AqQueue {
165181
async deqOne() {
166182
errors.assertArgCount(arguments, 0, 0);
167183
const msgImpl = await this._impl.deqOne();
168-
if (msgImpl) {
169-
const msg = new AqMessage();
170-
msg._impl = msgImpl;
171-
msg._payloadTypeClass = this._payloadTypeClass;
172-
return msg;
173-
}
184+
if (msgImpl)
185+
return this._makeMessage(msgImpl);
174186
}
175187

176188
//---------------------------------------------------------------------------
@@ -200,7 +212,8 @@ class AqQueue {
200212
for (let i = 0; i < messages.length; i++) {
201213
verifiedMessages[i] = this._verifyMessage(messages[i]);
202214
}
203-
return await this._impl.enqMany(verifiedMessages);
215+
const msgImpls = await this._impl.enqMany(verifiedMessages);
216+
return msgImpls.map(i => this._makeMessage(i));
204217
}
205218

206219
//---------------------------------------------------------------------------
@@ -211,7 +224,8 @@ class AqQueue {
211224
async enqOne(message) {
212225
errors.assertArgCount(arguments, 1, 1);
213226
message = this._verifyMessage(message);
214-
return await this._impl.enqOne(message);
227+
const msgImpl = await this._impl.enqOne(message);
228+
return this._makeMessage(msgImpl);
215229
}
216230

217231
//---------------------------------------------------------------------------

lib/connection.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,19 @@ class Connection extends EventEmitter {
10391039
return info;
10401040
}
10411041

1042+
//---------------------------------------------------------------------------
1043+
// instanceName
1044+
//
1045+
// Returns the Oracle Database instance name associated with the connection.
1046+
// This is the equivalent of the SQL expression:
1047+
// sys_context('userenv', 'instance_name')
1048+
//---------------------------------------------------------------------------
1049+
get instanceName() {
1050+
if (this._impl)
1051+
return this._impl.getInstanceName();
1052+
return undefined;
1053+
}
1054+
10421055
//---------------------------------------------------------------------------
10431056
// internalName
10441057
//
@@ -1227,7 +1240,7 @@ class Connection extends EventEmitter {
12271240
errors.assertArgCount(arguments, 2, 2);
12281241
errors.assertParamValue(typeof name === 'string', 1);
12291242
errors.assertParamValue(nodbUtil.isObject(options), 2);
1230-
options = {...options};
1243+
options = {name: name, ...options};
12311244
errors.assertParamPropUnsignedInt(options, 2, "namespace");
12321245
if (options.namespace === undefined)
12331246
options.namespace = constants.SUBSCR_NAMESPACE_DBCHANGE;
@@ -1253,14 +1266,13 @@ class Connection extends EventEmitter {
12531266
errors.assert(this._impl, errors.ERR_INVALID_CONNECTION);
12541267

12551268
const inSubscr = _subscriptions.get(name);
1256-
let outValue = await this._impl.subscribe(inSubscr, options);
1269+
const outValue = await this._impl.subscribe(inSubscr, options);
12571270
let subscription;
12581271
if (options.namespace === constants.SUBSCR_NAMESPACE_DBCHANGE) {
12591272
subscription = outValue.subscription;
12601273
delete outValue.subscription;
12611274
} else {
12621275
subscription = outValue;
1263-
outValue = undefined;
12641276
}
12651277
_subscriptions.set(name, subscription);
12661278
return outValue;

lib/errors.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ const ERR_UNEXPECTED_DATA = 113;
116116
const ERR_OSON_FIELD_NAME_LIMITATION = 114;
117117
const ERR_ORACLE_NUMBER_NO_REPR = 115;
118118
const ERR_UNSUPPORTED_VERIFIER_TYPE = 116;
119-
const ERR_INVALID_PRIVATE_KEY = 117;
120119
const ERR_THIN_CONNECTION_ALREADY_CREATED = 118;
121120
const ERR_UNSUPPORTED_CONVERSION = 119;
122121
const ERR_FETCH_TYPE_HANDLER_RETURN_VALUE = 120;
@@ -178,7 +177,6 @@ adjustErrorXref.set("OCI-22165", [ERR_INVALID_COLL_INDEX_SET, /index \[([0-9]+)\
178177
adjustErrorXref.set("ORA-00028", ERR_CONNECTION_CLOSED);
179178
adjustErrorXref.set("ORA-00600", ERR_CONNECTION_CLOSED);
180179
adjustErrorXref.set("ORA-24338", ERR_INVALID_REF_CURSOR);
181-
adjustErrorXref.set("ORA-24422", ERR_POOL_HAS_BUSY_CONNECTIONS);
182180
adjustErrorXref.set("ORA-25708", ERR_TOKEN_HAS_EXPIRED);
183181

184182
// define mapping for error messages
@@ -355,8 +353,6 @@ messages.set(ERR_ORACLE_NUMBER_NO_REPR, // NJS-115
355353
'value cannot be represented as an Oracle Database number');
356354
messages.set(ERR_UNSUPPORTED_VERIFIER_TYPE, // NJS-116
357355
'password verifier type 0x%s is not supported by node-oracledb in Thin mode');
358-
messages.set(ERR_INVALID_PRIVATE_KEY, // NJS-117
359-
'invalid private key. Headers and footers are not allowed');
360356
messages.set(ERR_THIN_CONNECTION_ALREADY_CREATED, // NJS-118
361357
'node-oracledb Thick mode cannot be enabled because a Thin mode connection has already been created');
362358
messages.set(ERR_UNSUPPORTED_CONVERSION, // NJS-119
@@ -612,10 +608,19 @@ function transformErr(err, fnOpt) {
612608
const pos = err.message.indexOf(":");
613609
if (pos > 0) {
614610
err.code = err.message.substr(0, pos);
611+
/* add Oracle Database Error Help Portal URL for database error
612+
messages, but only in thin mode since this is done
613+
automatically in thick mode with Oracle Client 23c and higher
614+
*/
615+
const settings = require('./settings.js');
616+
if (err.errorNum && settings.thin) {
617+
err.message += '\n' + 'Help: https://docs.oracle.com/error-help/db/ora-' +
618+
`${err.errorNum.toString().padStart(5, '0')}/`;
619+
}
615620
if (adjustErrorXref.has(err.code)) {
616621
let args = [];
617622
let driverErrorNum;
618-
let driverErrorInfo = adjustErrorXref.get(err.code);
623+
const driverErrorInfo = adjustErrorXref.get(err.code);
619624
if (typeof driverErrorInfo === 'number') {
620625
driverErrorNum = driverErrorInfo;
621626
} else {
@@ -748,7 +753,6 @@ module.exports = {
748753
ERR_UNEXPECTED_DATA,
749754
ERR_OSON_FIELD_NAME_LIMITATION,
750755
ERR_OSON_VERSION_NOT_SUPPORTED,
751-
ERR_INVALID_PRIVATE_KEY,
752756
ERR_THIN_CONNECTION_ALREADY_CREATED,
753757
ERR_UNSUPPORTED_CONVERSION,
754758
ERR_FETCH_TYPE_HANDLER_RETURN_VALUE,

lib/impl/connection.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,15 @@ class ConnectionImpl {
226226
errors.throwNotImplemented("getting the external name");
227227
}
228228

229+
//---------------------------------------------------------------------------
230+
// getInstanceName()
231+
//
232+
// Returns the Oracle Database instance name associated with the connection.
233+
//---------------------------------------------------------------------------
234+
getInstanceName() {
235+
errors.throwNotImplemented("getting the Oracle Database instance name.");
236+
}
237+
229238
//---------------------------------------------------------------------------
230239
// getInternalName()
231240
//

lib/impl/resultset.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,17 @@ class ResultSetImpl {
111111
if (metadata.dbType === types.DB_TYPE_NUMBER &&
112112
metadata.fetchType === types.DB_TYPE_NUMBER) {
113113
converter = (v) => (v === null) ? null : parseFloat(v);
114-
} else if (metadata.fetchType === types.DB_TYPE_VARCHAR &&
115-
(metadata.dbType === types.DB_TYPE_BINARY_DOUBLE ||
114+
} else if (metadata.fetchType === types.DB_TYPE_VARCHAR) {
115+
if (metadata.dbType === types.DB_TYPE_BINARY_DOUBLE ||
116116
metadata.dbType === types.DB_TYPE_BINARY_FLOAT ||
117117
metadata.dbType === types.DB_TYPE_DATE ||
118118
metadata.dbType === types.DB_TYPE_TIMESTAMP ||
119119
metadata.dbType === types.DB_TYPE_TIMESTAMP_LTZ ||
120-
metadata.dbType === types.DB_TYPE_TIMESTAMP_TZ)) {
121-
converter = (v) => (v === null) ? null : v.toString();
120+
metadata.dbType === types.DB_TYPE_TIMESTAMP_TZ) {
121+
converter = (v) => (v === null) ? null : v.toString();
122+
} else if (metadata.dbType === types.DB_TYPE_RAW) {
123+
converter = (v) => (v === null) ? null : v.toString('hex').toUpperCase();
124+
}
122125
}
123126
if (userConverter && converter) {
124127
const internalConverter = converter;

0 commit comments

Comments
 (0)