From 3a351513cd938ec0b4f8f4a0c0eb2dad93f064ce Mon Sep 17 00:00:00 2001 From: Sharad Chandran R Date: Fri, 10 May 2024 13:28:34 +0530 Subject: [PATCH] Fixed exponent check condition for out-of-bounds number(Issue #1659) --- doc/src/release_notes.rst | 9 +++++++++ lib/impl/datahandlers/buffer.js | 4 ++-- test/invalidNumber.js | 16 +++++++++++++--- test/list.txt | 3 ++- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/doc/src/release_notes.rst b/doc/src/release_notes.rst index d6a135a97..bc8471e08 100644 --- a/doc/src/release_notes.rst +++ b/doc/src/release_notes.rst @@ -7,6 +7,15 @@ node-oracledb Release Notes For deprecated and desupported features, see :ref:`Deprecations and desupported features `. +node-oracledb `v6.5.1 `__ (TBD) +------------------------------------------------------------------------------------------------------- + +Thin Mode Changes ++++++++++++++++++ + +#) Fixed exponent check condition for out-of-bounds number. + See `Issue #1659 `__. + node-oracledb `v6.5.0 `__ (2 May 2024) ------------------------------------------------------------------------------------------------------- diff --git a/lib/impl/datahandlers/buffer.js b/lib/impl/datahandlers/buffer.js index 7a0928dfa..2049f896f 100644 --- a/lib/impl/datahandlers/buffer.js +++ b/lib/impl/datahandlers/buffer.js @@ -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); } diff --git a/test/invalidNumber.js b/test/invalidNumber.js index 75ba27819..93a2663f7 100644 --- a/test/invalidNumber.js +++ b/test/invalidNumber.js @@ -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); @@ -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( @@ -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 + }); diff --git a/test/list.txt b/test/list.txt index 0fb900f85..32dc6464c 100755 --- a/test/list.txt +++ b/test/list.txt @@ -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