Fixed bug in identifying bind variables in SQL and PL/SQL statements containing a single line comment at the end of the statement

This commit is contained in:
Sharad Chandran R 2024-03-11 12:41:19 +05:30
parent 05f1645cbf
commit b287d414cb
3 changed files with 10 additions and 7 deletions

View File

@ -65,6 +65,9 @@ Thin Mode Changes
idle connections present in the free connection list.
`Issue #1633 <https://github.com/oracle/node-oracledb/issues/1633>`__.
#) Fixed bug in identifying bind variables in SQL and PL/SQL statements
containing a single line comment at the end of the statement.
Thick Mode Changes
++++++++++++++++++

View File

@ -219,10 +219,10 @@ class Parser {
/**
* Single line comments consist of two dashes and all characters up to the
* next line break. This method is called when the first dash is detected
* and checks for the subsequent dash. If found, the single line comment
* is traversed and the current position is updated; otherwise, the
* current position is left untouched.
* next line break (or the end of the data). This method is called when
* the first dash is detected and checks for the subsequent dash. If found,
* the single line comment is traversed and the current position is updated;
* otherwise, the current position is left untouched.
*/
_parseSingleLineComment() {
let inComment = false;
@ -233,15 +233,15 @@ class Parser {
ch = this.sqlData[pos];
if (!inComment) {
if (ch !== '-') {
break;
return;
}
inComment = true;
} else if (ch === '\n') {
this.pos = pos;
break;
}
pos += 1;
}
this.pos = pos;
}
/**

View File

@ -83,7 +83,7 @@ describe('289. sqlParser.js', function() {
it('289.3 single line comment', async () => {
const sql = `--begin :value2 := :a + :b + :c +:a +3; end;
begin :value2 := :a + :c +3; end;`;
begin :value2 := :a + :c +3; end; -- not a :bindv`;
const info = await conn.getStatementInfo(sql);
assert.deepStrictEqual(info.bindNames, ["VALUE2", "A", "C"]);
}); // 289.3