orientdb icon indicating copy to clipboard operation
orientdb copied to clipboard

[2.1.2 GA] (reqression) SQL parser raises syntax error on statements that worked with previous versions

Open giastfader opened this issue 11 years ago • 7 comments

Hi, In v.1.7.9 and 2.0-m3 I have a statement similar to this one:

insert into test set other = (insert into test2 set key=2)

that actually works.

However in 2.1.2 the SQL parser raises the following syntax error:

Error: com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error on parsing command at position #0: Encountered " <SET> "set "" at line 1, column 18.
Was expecting one of:
    <EOF> 
    <SELECT> ...
    <FROM> ...
    <RETURN> ...
    <UNSAFE> ...
    "(" ...
    ";" ...
    <CLUSTER> ...
    "(" ...

Steps to reproduce the issue:

create database remote:localhost/test root <root_password> memory
create class test
create class test2
insert into test set other = (insert into test2 set key=2)

With versions 1.7.9 and 2.0 I have no errors:

Inserted record 'test#11:0{other:#12:0} v0' in 0.004000 sec(s).

select from test
----+-----+-----
#   |@RID |other  
----+-----+-----
0   |#11:0|#12:0
----+-----+-----

With v.2.1.2:

Error: com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error on parsing command at position #0: Encountered " <SET> "set "" at line 1, column 18.
Was expecting one of:
    <EOF> 
    <SELECT> ...
    <FROM> ...
    <RETURN> ...
    <UNSAFE> ...
    "(" ...
    ";" ...
    <CLUSTER> ...
    "(" ...

I will post other cases in comments

giastfader avatar Sep 24 '15 10:09 giastfader

Here is an example involving a class that as a '-' in its name:

orientdb {db=test}> create class with-dash
Class created successfully. Total classes in database now: 11

With 1.7.9 / 2.0-M3:

orientdb {db=test}> select from with-dash
0 item(s) found. Query executed in 0.001 sec(s).

With 2.1.2 GA:

orientdb {db=test}> select from with-dash
Error: com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error on parsing command at position #0: Encountered " "-" "- "" at line 1, column 17.
Was expecting one of:
    <EOF> 
    <WHERE> ...
    <ORDER> ...
    <GROUP> ...
    <LIMIT> ...
    <SKIP2> ...
    <OFFSET> ...
    <TIMEOUT> ...
    <FETCHPLAN> ...
    <LOCK> ...
    <LET> ...
    <NOCACHE> ...
    <PARALLEL> ...
    <UNWIND> ...
    ";" ...
    <LET> ...
    <WHERE> ...
    <GROUP> ...
    <ORDER> ...
    <UNWIND> ...
    <SKIP2> ...
    <OFFSET> ...
    <LIMIT> ...
    <FETCHPLAN> ...
    <TIMEOUT> ...
    <LOCK> ...
    <PARALLEL> ...
    <NOCACHE> ...
    <NOCACHE> ...

giastfader avatar Sep 24 '15 10:09 giastfader

Ciao @giastfader

Yes, in v 2.1 we introduced a more strict validation policy, so identifier names (class and property names) cannot contain some special characters like dots and -. You have two alternatives to fix the problem:

  • disable strict validation (from Studio, DB tab, configuration, disable strictSql at the bottom of the page). This will make the system compatible with the old parsing rules
  • quote classes with special characters, using backtick, eg.
select from `with-dash`

I'm closing this, please reopen if you have problems with this or if you need further help

Thanks

Luigi

luigidellaquila avatar Sep 24 '15 10:09 luigidellaquila

Hi Luigi, ok for the classes with '-'.

But please cast a glance to the first case: the insert statement.

giastfader avatar Sep 24 '15 10:09 giastfader

right, I missed it... Reopening, I can fix it quickly

Thanks

Luigi

luigidellaquila avatar Sep 24 '15 10:09 luigidellaquila

It seems that ALTER DATABASE custom strictSQL=false solves also the first problem.

I do not know if it is still an issue or a intentional behavior of the parser.

giastfader avatar Sep 24 '15 10:09 giastfader

yes, disabling strict sql also fixes that, but it that case it should also be allowed with strict sql enabled

luigidellaquila avatar Sep 24 '15 11:09 luigidellaquila

Hi @giastfader I fixed it in both 2.1.x and develop branches Closing, please reopen if you find something wrong Thanks Luigi

luigidellaquila avatar Sep 24 '15 16:09 luigidellaquila