Menu

#1395 sql query cannot have -- (dash dash) token in strings

SQuirreL
open
nobody
None
low
2019-07-11
2019-06-16
Rich Coe
No

-- (dash dash) the sql comment token gets interpreted as the start of a comment if it is included in an sql statement within single quotes '--' or double "--".

I tried searching for '--' in the bugs to see if it's been reported, but '--' is interpreted as an error.

Probably not even an issue for most users typing adhoc queries in the UI.
I noticed because I was running legacy sql from an old file.

If I get the chance, I'll look at the input interpreter and try my hand at patching it.

Discussion

  • Gerd Wagner

    Gerd Wagner - 2019-06-17

    Sorry, I can't reproduce the problem. Could you post an example SQL?

     
  • Rich Coe

    Rich Coe - 2019-06-17

    I lost the single quote example, I'll keep looking.
    Here's one version of the double:
    select '-- ' || to_char(CURRENT_TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS') as "-- Insert Generated DateTime" from dual

    this version will work with the space inserted
    select '-- ' || to_char(CURRENT_TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS') as "- - Insert Generated DateTime" from dual

     
  • Gerd Wagner

    Gerd Wagner - 2019-07-11

    The problem I could reproduce was that the string concatenation '||' was marked as error. Triggered by this a new parser was integrated, see https://github.com/JSQLParser/JSqlParser. It may be that other problems you saw are now solved, too. It would be nice if you had a look at the latest snapshot:
    https://sourceforge.net/projects/squirrel-sql/files/3-snapshots/

    Thanks Gerd

     

Log in to post a comment.

MongoDB Logo MongoDB