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

Escaped entities and newlines inside quotes cause an exception in the SQL parser #9554

Open
MarttiR opened this issue Mar 1, 2021 · 1 comment
Milestone

Comments

@MarttiR
Copy link

MarttiR commented Mar 1, 2021

OrientDB Version: 3.1.8 (docker)

In some cases, quoted strings containing escaped entities and/or newlines ("foo \n bar") fail to be parsed by the SQL parser. This happens both from Studio and through OrientJS batch.

Expected behavior

Newlines and escaped entities inside quoted strings do not crash the parser.

Actual behavior

Having any escaped character or a newline inside a quoted string will cause an exception in the SQL parser:

com.orientechnologies.orient.core.sql.parser.TokenMgrError: Lexical error at line 148, column 47.  Encountered: "\n" (10), after : "\""

Steps to reproduce

This seems to happen wherever there can be a quoted string. Some examples:

eval() doesn't like multiline expressions:

LET $test = eval("
  TRUE
  OR FALSE
");

RegExp is prone to breakage due to the frequent need to escape some characters:

CREATE FUNCTION newlineTest
"var foo = \"[test]\";
return /\\[[a-z]+\\]/.test(foo);"
IDEMPOTENT TRUE
LANGUAGE JAVASCRIPT;

Related issues

Newline in batch CREATE FUNCTION causes lexical error in OrientDB – orientjs#444

query runs fine in console, in web gui, but not over REST-API – orientdb#8206 – the same happens with single quotes.
OrientDB 2.1 Migration - newlines in quoted SQL string – oriendb#4837

@lvca
Copy link
Member

lvca commented Jun 26, 2021

Is this happening with one statement SQL or only with scripts?

@tglman tglman added this to the 3.1.x milestone Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants