Skip to content

Commit b287d41

Browse files
committed
Fixed bug in identifying bind variables in SQL and PL/SQL statements containing a single line comment at the end of the statement
1 parent 05f1645 commit b287d41

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

doc/src/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ Thin Mode Changes
6565
idle connections present in the free connection list.
6666
`Issue #1633 <https://github.com/oracle/node-oracledb/issues/1633>`__.
6767

68+
#) Fixed bug in identifying bind variables in SQL and PL/SQL statements
69+
containing a single line comment at the end of the statement.
70+
6871
Thick Mode Changes
6972
++++++++++++++++++
7073

lib/thin/statement.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ class Parser {
219219

220220
/**
221221
* Single line comments consist of two dashes and all characters up to the
222-
* next line break. This method is called when the first dash is detected
223-
* and checks for the subsequent dash. If found, the single line comment
224-
* is traversed and the current position is updated; otherwise, the
225-
* current position is left untouched.
222+
* next line break (or the end of the data). This method is called when
223+
* the first dash is detected and checks for the subsequent dash. If found,
224+
* the single line comment is traversed and the current position is updated;
225+
* otherwise, the current position is left untouched.
226226
*/
227227
_parseSingleLineComment() {
228228
let inComment = false;
@@ -233,15 +233,15 @@ class Parser {
233233
ch = this.sqlData[pos];
234234
if (!inComment) {
235235
if (ch !== '-') {
236-
break;
236+
return;
237237
}
238238
inComment = true;
239239
} else if (ch === '\n') {
240-
this.pos = pos;
241240
break;
242241
}
243242
pos += 1;
244243
}
244+
this.pos = pos;
245245
}
246246

247247
/**

test/sqlParser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('289. sqlParser.js', function() {
8383

8484
it('289.3 single line comment', async () => {
8585
const sql = `--begin :value2 := :a + :b + :c +:a +3; end;
86-
begin :value2 := :a + :c +3; end;`;
86+
begin :value2 := :a + :c +3; end; -- not a :bindv`;
8787
const info = await conn.getStatementInfo(sql);
8888
assert.deepStrictEqual(info.bindNames, ["VALUE2", "A", "C"]);
8989
}); // 289.3

0 commit comments

Comments
 (0)