Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NJS-097: no bind placeholder when I have apostrophe in comment #1605

Closed
ncollins-vs opened this issue Sep 8, 2023 · 2 comments
Closed

NJS-097: no bind placeholder when I have apostrophe in comment #1605

ncollins-vs opened this issue Sep 8, 2023 · 2 comments

Comments

@ncollins-vs
Copy link

  1. What versions are you using?

Node-oracledb 6.1.0 thin mode
Oracle DB 19 on Amazon RDS

  1. Is it an error or a hang or a crash?

Crash

  1. What error(s) or behavior you are seeing?

When I have an apostrophe in a comment followed by code with a bind variable node-oracledb doesn't recognize the bind variable and gives me the error NJS-097: no bind placeholder.

I've traced this error to this line, which happens to look almost exactly like some code I wrote (and just fixed) to find bind variables in a SQL statement. The fix I decided on for my code was to edit the regex to disallow multi-line strings since that fixed my specific problem and I don't believe multi-line strings are valid SQL (though if they are you'd have to come up with a different solution. It may also work to strip comments before strings but that opens up other issues.

  1. Include a runnable Node.js script that shows the problem.

Here's the specific problem I ran into:

const SQL = `
-- Apostrophes don't work
select * from example where age = :example and name = 'example';
`;
conn.execute(SQL, {example: ''});

In that case it strips the "string" from the apostrophe in don't to the first single quote of 'example', so it can't find the bind parameter :example.

Simply reordering the filters doesn't work because it could think you could have comments in strings (i.e. and flag = '--flag'). There may also be some existing issues in the interaction between single-line and multi-line comments. It may not be possible to do all the stripping you need to do properly with regexes.

@ncollins-vs ncollins-vs added the bug label Sep 8, 2023
@cjbj
Copy link
Member

cjbj commented Sep 8, 2023

@ncollins-vs Thanks for the report. We have some improvements planned, similar to this done for python-oracledb.

@sharadraju
Copy link
Member

This is fixed in the 6.2 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants