Details for the issue
Selecting values in double quotes containing double hyphen substring returns "unrecognized token" error.
Please see example below.
Useful extra information
I'm opening this issue because:
I'm using DB4S on:
I'm using DB4S version:
I have also:
The text was updated successfully, but these errors were encountered:
Oops. Just realised something that should have been obvious to me right away before.
This is probably not a bug after all. With SQL, the single and double quote characters aren't the same thing.
In the above example, the table
Further reference info, in case it's useful:
With your double quote example, the "unrecognized token" message is probably meaning that it's looking for a field called (literally) "anything--something", and not finding it.
Does that help?
Thank you for pointing to SQLite documentation.
Hmmm, yeah you're right. I've just tried it here with the sqlite3 client (and older version, 3.7.17 on my CentOS 7 desktop), and a recent build of DB4S.
It looks like DB4S is getting misunderstanding the double quotes. For example, with this (from above):
In the sqlite3 CLI it works, adding a new row into the table
Looking at that error message, there's an extra
So... yep this does seem like a bug. Our Execute SQL tab should accept anything that the SQLite CLI does. Thanks for being persistent.
In the code for removing comments from SQL statements we have to make sure to only match the '--' characters when they are not inside a quoted string or identifier. This works fine and as expected for single quotes. However, for double quotes it doesn't. This is fixed by this commit. See issue #1270.
We need to make sure it's working for all these statements:
SELECT "something--something" -- comment SELECT 'something--something' -- comment SELECT "something--some'thing" -- comment SELECT 'something--some"thing' -- comment
And as a bonus maybe for these too:
SELECT `something--something` FROM table -- comment SELECT [something--something] FROM table -- comment
And for these:
SELECT '/*test*/' -- comment SELECT "/*test*/" -- comment SELECT '/*te"st*/' -- comment SELECT "/*te'st*/" -- comment SELECT `/*test*/` FROM table -- comment SELECT [/*test*/] FROM table -- comment