Skip to content

Commit f4ce930

Browse files
committed
Fix for GH issue #1625 - Bug with multi-line comments with multiple asterisks
1 parent 33efef5 commit f4ce930

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

doc/src/release_notes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ Common Changes
5252
Thin Mode Changes
5353
++++++++++++++++++
5454

55+
#) Fixed bug in parsing SQL statements containing multi-line comments
56+
with multiple asterisks before the closing slash.
57+
`Issue #1625 <https://github.com/oracle/node-oracledb/issues/1625>`__.
58+
5559
#) Fixed bug that caused an 'ORA-03120' exception to be thrown when
5660
a string whose size is greater than "database initialization parameter",
5761
``MAX_STRING_SIZE`` is bound to a PL/SQL function.

lib/thin/statement.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class Parser {
142142
break;
143143
}
144144
inComment = true;
145-
} else if (!exitingComment && ch === '*') {
145+
} else if (ch === '*') {
146146
exitingComment = true;
147147
} else if (exitingComment) {
148148
if (ch === '/') {

test/getStmtInfo.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,4 +481,16 @@ describe('162. getStmtInfo.js', function() {
481481
key = key + 1;
482482
}
483483
});
484+
485+
it('162.36 Multiple line and Multiple Asterisks', async function() {
486+
const sql = `/****--select * from :a where :a = 1
487+
select * from table_names where :a = 1****/
488+
select :table_name, :value from dual`;
489+
const expectedRes = ['TAB', 'VAL'];
490+
491+
const info = await conn.getStatementInfo(sql);
492+
assert.deepStrictEqual(info.bindNames, ['TABLE_NAME', 'VALUE']);
493+
const result = await conn.execute(sql, expectedRes);
494+
assert.deepStrictEqual(result.rows[0], expectedRes);
495+
});
484496
});

test/list.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4159,6 +4159,7 @@ oracledb.OUT_FORMAT_OBJECT and resultSet = true
41594159
162.33 Bind Variable before, inbetween and after comments in sql
41604160
162.34 ignore literals only during bind processing
41614161
162.35 Parse and Execute twice
4162+
162.36 Multiple line and Multiple Asterisks
41624163

41634164
163. executeMany1.js
41644165
163.1 inserts many rows with bind by name

0 commit comments

Comments
 (0)