Fixed a regression in AQ that caused the deq functions to return an invalid object in 6.4 instead of undefined, which was returned in earlier releases (See Issue #1656)

This commit is contained in:
Sharad Chandran R 2024-05-02 15:02:22 +05:30
parent 29cbe3c145
commit 523d2961fa
5 changed files with 26 additions and 1 deletions

View File

@ -38,6 +38,11 @@ Thick Mode Changes
Additionally, this fix resolves the issue related to JS numbers with
precisions where `2.3` is returned as `2.300003`.
#) Fixed a regression that caused ``deqOne()``and ``deqMany()`` to return an
invalid object in 6.4 instead of undefined, which was returned in the
previous releases.
See `Issue #1656 <https://github.com/oracle/node-oracledb/issues/1656>`__.
node-oracledb `v6.4.0 <https://github.com/oracle/node-oracledb/compare/v6.3.0...v6.4.0>`__ (11 Mar 2024)
--------------------------------------------------------------------------------------------------------

View File

@ -181,7 +181,7 @@ class AqQueue {
async deqOne() {
errors.assertArgCount(arguments, 0, 0);
const msgImpls = await this._impl.deq(1);
if (msgImpls)
if (msgImpls.length > 0)
return this._makeMessage(msgImpls[0]);
}

View File

@ -357,6 +357,10 @@ static bool njsAqQueue_deqAsync(njsBaton* baton)
if (baton->numMsgProps == 1) {
if (dpiQueue_deqOne(queue->handle, &baton->msgProps[0]) < 0)
return njsBaton_setErrorDPI(baton);
// Handle the case when message queue is empty
if (baton->msgProps[0] == NULL)
baton->numMsgProps = 0;
} else {
// deqMany case
if (dpiQueue_deqMany(queue->handle, &baton->numMsgProps,

View File

@ -190,4 +190,18 @@ describe('217. aq1.js', function() {
}
}); // 217.4
it('217.5 deqOne on empty queue', async () => {
const queue2 = await conn.getQueue(rawQueueName);
queue2.deqOptions.wait = oracledb.AQ_DEQ_NO_WAIT;
const message = await queue2.deqOne();
assert.strictEqual(message, undefined);
});
it('217.6 deqMany on empty queue', async () => {
const queue2 = await conn.getQueue(rawQueueName);
queue2.deqOptions.wait = oracledb.AQ_DEQ_NO_WAIT;
const messages = await queue2.deqMany(1);
assert.deepStrictEqual(messages, []);
});
});

View File

@ -4634,6 +4634,8 @@ oracledb.OUT_FORMAT_OBJECT and resultSet = true
217.2 examples/aqoptions.js
217.3 examples/aqmulti.js
217.4 one message in enqMany/deqMany
217.5 deqOne on empty queue
217.6 deqMany on empty queue
218. aq2.js
218.1 examples/aqobject.js