question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error while parsing literals with backslash

See original GitHub issue

Describe the bug Can’t properly parse the statement when

  1. Backslash is the last character of a literal;
  2. The literal is not the last value of a sequence.

To Reproduce Steps to reproduce the behavior:

  1. Example: CCJSqlParserUtil.parseStatements("""INSERT INTO "a"."b"("c", "d", "e") VALUES ('c c\', 'dd', 'ee\')""") (Kotlin)
  2. Exception:
net.sf.jsqlparser.JSQLParserException: Encountered unexpected token: "dd" <S_IDENTIFIER>
    at line 1, column 53.

Was expecting one of:

    "&"
    ")"
    ","
    "::"
    "<<"
    ">>"
    "COLLATE"
    "["
    "^"
    "|"
  1. Note that CCJSqlParserUtil.parseStatements("""INSERT INTO "a"."b"("c", "d", "e") VALUES ('c c', 'dd', 'ee\')""") won’t trigger the exception.

Expected behavior

The literals 'c c\' and 'dd'should be properly parsed.

System

  • Database: Oracle
  • Kotlin Version: 1.4.21-release-IJ2020.2-1
  • Java Version: 1.8
  • JSqlParser version: 4.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:35 (20 by maintainers)

github_iconTop GitHub Comments

1reaction
manticore-projectscommented, May 25, 2021

Yes, this was exactly what I have suggested to the @wumpz. As kind of Pre-Processing and Post-Processing outside of the Parser itself.

On Mon, 2021-05-24 at 21:06 -0700, Xingcan Cui wrote:

Thanks for your insights! @manticore-projects To temporarily fix this problem, I replace all \ with \ before parsing the SQL and replace them back after the parsing process. Do you think this is a feasible workaround? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

0reactions
revuskycommented, Jun 18, 2021

This is a very one-sided relationship, you know. I’m giving you plenty and not getting much for myself in return. Well, fine, maybe you don’t have to much to offer me right now. All I would ask now is that you please, please, please, try your best to stop talking shit.

Totally my mistake, but no worries. I won’t bother you any further so you can fully focus on your work and your more qualified users.

Andreas, you really need to stop this kind of thing. It’s really not a good thing, not a good behavior pattern.

Look, you’re now insinuating something about me that has no basis in reality. For the record, I never said anything about you or any other user being “qualified”. And I never would say such a thing because that does not even correspond to my whole way of thinking. You must be projecting your own inferiority complex.

Regardless, this kind of thing has a sleazy sort of feel to it, kind of makes my skin crawl.

I didn’t really want to get into this conversation even. Truth told, I basically wrote off this community long ago. I only entered the conversation because you were making some very bizarre misstatements. For me, the real tipping point in this was when you casually said you had “doubts about JavaCC21’s ‘maturity’”

Well, as I recall, you said that you had read the full history of this that I wrote. So, surely you understand that JavaCC21 (previously FreeCC when it was initially forked back 2008) is a more advanced version of the tool that these people already happen to be using! And it’s the result of systematically fixing every well-known, longstanding bug in the abandoned legacy tool.

To be clear, generally speaking it is not invalid to question the “maturity” of JavaCC21 (or whatever thing.) BUT… when we’re in a context in which the only real point of comparison is a far more backward of the very same tool… that’s just… And finally, it’s very hard to interpret this generously. Anybody can look at the issues page on JavaCC21 and see that I was very responsive and helpful to you. After that, I don’t think you should be here (or anywhere else!) spreading this kind of sleazy FUD. I can’t turn a blind eye to this.

Back in my earlier run at open source, the FreeMarker days, I put my trust in some very low-quality, treacherous people, mostly I’m thinking of Daniel Dekany, a real back-stabber. I try to learn from the past and any sign that somebody is a treacherous backstabber, I intend to extirpate the problem very quickly this time round. So I just banned you from my world. But never mind. It’s not really personal.

(Actually, the above is formulaic. It is personal.)

Let this thread/issue be on parsing Quoted Strings in the different SQL Dialects solely.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why can't Python's raw string literals end with a single ...
So any character following a backslash is part of raw string. Once parser enters a raw string (non Unicode one) and encounters a...
Read more >
Strings - Manual - PHP
All other instances of backslash will be treated as a literal backslash: this ... PHP Parse error: Invalid indentation - tabs and spaces...
Read more >
Simple question - end a raw string with a single backslash ?
I am trying to write a simple expression to build a raw string that ends in a single backslash. My understanding is that...
Read more >
Python Raw String - DigitalOcean
When a backslash is followed by a quote in a raw string, it's escaped. However, the backslash also remains in the result. Because...
Read more >
Raw string parsing fails with backslash as last character
http://docs.python.org/dev/reference/lexical_analysis.html#string-literals r"\" is not a valid string literal (even a raw string cannot end in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found