difference between query parsing using APIs?

24 views
Skip to first unread message

john davids

unread,
Jan 29, 2015, 6:18:16 AM1/29/15
to orient-...@googlegroups.com
Hello, 

I'm using 2.0.1 and probably doing something wrong, but I execute some queries using Studio and they run, but the same queries using Java API (no prepared arguments, just plain sql) give me an OCommandSQLParsingException.

See an example below. The same query is sent as POST from the Studio web app and works.

Exception in thread "main" com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error on parsing command at position #89: Found unexpected keyword '
traverse out('Relation') from #12:4 while ( ( relation = 'type of' or relation is null ) and ( eval('not ($history contains #12:6)') ))

Could you give me some hints why this happens, or how can I avoid it?

Thank you!

john davids

unread,
Jan 29, 2015, 8:25:43 AM1/29/15
to orient-...@googlegroups.com
I tried to look at the code that executes on the server side the post from the Studio client. I think it is OServerCommandPostCommand.execute() method.

I copy pasted that code, in my code

      final OCommandRequestText cmd = (OCommandRequestText) OCommandManager.instance().getRequester("sql");

      cmd.setText(text);
      ...

      final OCommandExecutor executor = OCommandManager.instance().getExecutor(cmd);
      executor.setContext(cmd.getContext());
      executor.setProgressListener(cmd.getProgressListener());
      executor.parse(cmd);

      ...

      response = db.command(cmd).execute();

I still get the same parsing error on my local client, and no error in Studio.
Do you think it is some kind of String encoding problem on my side?

john davids

unread,
Jan 29, 2015, 8:53:20 AM1/29/15
to orient-...@googlegroups.com
Ok! I figured it out!

The presence of \t (tabs) in the sql messed up the parser... maybe you can do a quick fix, who knows how many hate the same problem :)
Reply all
Reply to author
Forward
0 new messages