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

Selecting vertex by id using prepared query. #4960

Closed
arditymeri opened this issue Sep 11, 2015 · 9 comments
Closed

Selecting vertex by id using prepared query. #4960

arditymeri opened this issue Sep 11, 2015 · 9 comments

Comments

@arditymeri
Copy link

I'm trying to use prepared queries for selecting a vertex by id, like:

graph.command(new OSQLSynchQuery<>("SELECT FROM ? ")).execute("#24:0")

I also noticed that this problem is happening whenever the id needs to occur in the query without surrounding quotes. Am I missing something on the syntax? Or is this a bug?

Here is the stacktrace:

Error on parsing query
Query:  ?
------^
com.orientechnologies.orient.core.exception.OQueryParsingException: Error on parsing query
Query:  ?
------^
    at com.orientechnologies.orient.core.sql.filter.OSQLTarget.<init>(OSQLTarget.java:76)
    at com.orientechnologies.orient.core.sql.OSQLEngine.parseTarget(OSQLEngine.java:440)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.parse(OCommandExecutorSQLSelect.java:200)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.parse(OCommandExecutorSQLSelect.java:78)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.parse(OCommandExecutorSQLDelegate.java:56)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.parse(OCommandExecutorSQLDelegate.java:37)
    at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.command(OAbstractPaginatedStorage.java:1178)
    at com.orientechnologies.orient.core.sql.query.OSQLQuery.run(OSQLQuery.java:71)
    at com.orientechnologies.orient.core.sql.query.OSQLSynchQuery.run(OSQLSynchQuery.java:85)
    at com.orientechnologies.orient.core.query.OQueryAbstract.execute(OQueryAbstract.java:33)
    at com.tinkerpop.blueprints.impls.orient.OrientGraphCommand.execute(OrientGraphCommand.java:48)
Caused by: com.orientechnologies.orient.core.exception.OCommandExecutionException: Class '?' was not found in current database
    at com.orientechnologies.orient.core.sql.filter.OSQLTarget.extractTargets(OSQLTarget.java:262)
    at com.orientechnologies.orient.core.sql.filter.OSQLTarget.<init>(OSQLTarget.java:67)
    ... 54 more
@arditymeri arditymeri changed the title Selecting a vertex using prepared query. Selecting vertex by id using prepared query. Sep 11, 2015
@wolf4ood
Copy link
Member

hi @arditymeri which version are you using?

@arditymeri
Copy link
Author

I'm using version 2.0.15

@wolf4ood
Copy link
Member

In 2.0.x prepared query does not work with parameter in from.
Has been fixed with the new Sql parser in 2.1

@arditymeri
Copy link
Author

Hi @maggiolo00 , thanks for your info. I can see it is working in version 2.1.

@luigidellaquila
Copy link
Member

Perfect, thanks.
Closing

@mohamnag
Copy link

I have to report the same problem here using orientDB v2.1.5 getting pretty same exception so that following command:

graph.command(new OSQLSynchQuery<>("SELECT FROM ?")).execute("#49:132")

results in an exception and the cause of that exception says:

com.orientechnologies.orient.core.exception.OCommandExecutionException: Class '?' was not found in current database

@kalmusr
Copy link

kalmusr commented Mar 25, 2016

Hi @mohamnag ! We had similar issues with a database using OrientDB v2.1.11. We could resolve the problem by a database export and reimport.

@luigidellaquila
Copy link
Member

Hi guys,

two points here:

  • I think param replacement for query target was fixed after 2.1.5, could you please try with latest stable?
  • your query won't work anyway, because you are passing a string, not a RID. To make it work you have to do something like
graph.command(new OSQLSynchQuery<>("SELECT FROM ?")).execute(new ORecordId(49, 132));

Thanks

Luigi

@luigidellaquila
Copy link
Member

Another little detail: there is no need to export/import the database, you can just set strictSql = true on the database

http://orientdb.com/docs/last/Release-2.1.0.html#strict-sql-parser

Thanks

Luigi

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

6 participants