Skip to content

Commit

Permalink
Fixed exponent check condition for out-of-bounds number(Issue #1659)
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadraju committed May 10, 2024
1 parent 9db4fcf commit 3a35151
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
9 changes: 9 additions & 0 deletions doc/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ node-oracledb Release Notes

For deprecated and desupported features, see :ref:`Deprecations and desupported features <deprecations>`.

node-oracledb `v6.5.1 <https://github.com/oracle/node-oracledb/compare/v6.5.0...v6.5.1>`__ (TBD)
-------------------------------------------------------------------------------------------------------

Thin Mode Changes
+++++++++++++++++

#) Fixed exponent check condition for out-of-bounds number.
See `Issue #1659 <https://github.com/oracle/node-oracledb/issues/1659>`__.

node-oracledb `v6.5.0 <https://github.com/oracle/node-oracledb/compare/v6.4.0...v6.5.0>`__ (2 May 2024)
-------------------------------------------------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions lib/impl/datahandlers/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -843,8 +843,8 @@ class BaseBuffer {
}

// throw exception if number cannot be represented as an Oracle Number
if (value.length > constants.NUMBER_MAX_DIGITS || exponent > 126 ||
exponent < -129) {
if (value.length > constants.NUMBER_MAX_DIGITS || exponent >= 126 ||
exponent <= -131) {
errors.throwErr(errors.ERR_ORACLE_NUMBER_NO_REPR);
}

Expand Down
16 changes: 13 additions & 3 deletions test/invalidNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const testsUtil = require('./testsUtil.js');

describe('299. invalidNumber.js', function() {
let conn;
let tableName = 'nodb_num';
const tableName = 'nodb_num';

before(async function() {
conn = await oracledb.getConnection(dbConfig);
Expand All @@ -51,8 +51,8 @@ describe('299. invalidNumber.js', function() {
await conn.close();
});

it('299.1 throws error for invalid numbers', async () => {
const idv = 1e+131;
it('299.1 throws error for invalid numbers(largest exponent + 1)', async () => {
const idv = 1e+126;
const sql = 'INSERT INTO nodb_num VALUES(:cid)';
const binds = { cid: { val: idv, type: oracledb.NUMBER}};
await assert.rejects(
Expand All @@ -61,4 +61,14 @@ describe('299. invalidNumber.js', function() {
);
}); // 299.1

it('299.2 throws error for invalid numbers(smallest exponent - 1)', async () => {
const idv = 1e-131;
const sql = 'INSERT INTO nodb_num VALUES(:cid)';
const binds = { cid: { val: idv, type: oracledb.NUMBER}};
await assert.rejects(
async () => await conn.execute(sql, binds),
/NJS-115:/
);
}); // 299.2

});
3 changes: 2 additions & 1 deletion test/list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5832,7 +5832,8 @@ oracledb.OUT_FORMAT_OBJECT and resultSet = true
298.10 no parallel delete operation on vector columns

299. invalidNumber.js
299.1 throws error for invalid numbers
299.1 throws error for invalid numbers(largest exponent + 1)
299.2 throws error for invalid numbers(smallest exponent - 1)

300. bigInt.js
300.1 can bind bigInts
Expand Down

0 comments on commit 3a35151

Please sign in to comment.