Skip to content

Commit 3a35151

Browse files
committed
Fixed exponent check condition for out-of-bounds number(Issue #1659)
1 parent 9db4fcf commit 3a35151

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

doc/src/release_notes.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ node-oracledb Release Notes
77

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

10+
node-oracledb `v6.5.1 <https://github.com/oracle/node-oracledb/compare/v6.5.0...v6.5.1>`__ (TBD)
11+
-------------------------------------------------------------------------------------------------------
12+
13+
Thin Mode Changes
14+
+++++++++++++++++
15+
16+
#) Fixed exponent check condition for out-of-bounds number.
17+
See `Issue #1659 <https://github.com/oracle/node-oracledb/issues/1659>`__.
18+
1019
node-oracledb `v6.5.0 <https://github.com/oracle/node-oracledb/compare/v6.4.0...v6.5.0>`__ (2 May 2024)
1120
-------------------------------------------------------------------------------------------------------
1221

lib/impl/datahandlers/buffer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,8 +843,8 @@ class BaseBuffer {
843843
}
844844

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

test/invalidNumber.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const testsUtil = require('./testsUtil.js');
3838

3939
describe('299. invalidNumber.js', function() {
4040
let conn;
41-
let tableName = 'nodb_num';
41+
const tableName = 'nodb_num';
4242

4343
before(async function() {
4444
conn = await oracledb.getConnection(dbConfig);
@@ -51,8 +51,8 @@ describe('299. invalidNumber.js', function() {
5151
await conn.close();
5252
});
5353

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

64+
it('299.2 throws error for invalid numbers(smallest exponent - 1)', async () => {
65+
const idv = 1e-131;
66+
const sql = 'INSERT INTO nodb_num VALUES(:cid)';
67+
const binds = { cid: { val: idv, type: oracledb.NUMBER}};
68+
await assert.rejects(
69+
async () => await conn.execute(sql, binds),
70+
/NJS-115:/
71+
);
72+
}); // 299.2
73+
6474
});

test/list.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5832,7 +5832,8 @@ oracledb.OUT_FORMAT_OBJECT and resultSet = true
58325832
298.10 no parallel delete operation on vector columns
58335833

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

58375838
300. bigInt.js
58385839
300.1 can bind bigInts

0 commit comments

Comments
 (0)