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

"select from ?" no longer works with OSQLAsynchQuery when upgrading to 2.2.12 #6896

Closed
1 task done
temilmg opened this issue Nov 9, 2016 · 10 comments
Closed
1 task done
Assignees
Labels

Comments

@temilmg
Copy link

temilmg commented Nov 9, 2016

OrientDB Version, operating system, or hardware.

  • v2.2.12

Operating System

  • Linux

Expected behavior and actual behavior

After upgrading to 2.2.12 from 2.1.17 Async query with positional parameter using java api does not work with a query like:

String query = "select @Rid,* from ?";

Steps to reproduce the problem

String query = "select @Rid,* from ?";
graph.command(new OSQLAsynchQuery(query,
new OCommandResultListener() {
@OverRide
public boolean result(Object iRecord) {
}

				@Override
				public void end() {

				}

				@Override
				public Object getResult() {
					// TODO Auto-generated method stub
					return null;
				}

The new method Object getResult() in the interface OCommandResultListener breaks the existing code. I am not sure what it should be used for?

After fixing the interface most of my queries work but "select from ?" doesn't work. Is it no longer allowed to do this kind of query or is it a regression bug?
here is the stack trace:

com.orientechnologies.orient.core.exception.OStorageException: Error on executing command: sql.select @Rid,* from ?
DB name="mxi2"
at com.orientechnologies.orient.client.remote.OStorageRemote.baseNetworkOperation(OStorageRemote.java:271)
at com.orientechnologies.orient.client.remote.OStorageRemote.networkOperationRetry(OStorageRemote.java:193)
at com.orientechnologies.orient.client.remote.OStorageRemote.networkOperation(OStorageRemote.java:204)
at com.orientechnologies.orient.client.remote.OStorageRemote.command(OStorageRemote.java:1136)
at com.orientechnologies.orient.core.sql.query.OSQLQuery.run(OSQLQuery.java:78)
at com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery.run(OSQLAsynchQuery.java:74)
at com.orientechnologies.orient.core.query.OQueryAbstract.execute(OQueryAbstract.java:33)
at com.tinkerpop.blueprints.impls.orient.OrientGraphCommand.execute(OrientGraphCommand.java:49)

@wolf4ood
Copy link
Member

hi @temilmg

do you see some exception on OrientDB logs?

@temilmg
Copy link
Author

temilmg commented Nov 21, 2016

No, all I get is the above stack-trace when running my code

@temilmg
Copy link
Author

temilmg commented Nov 29, 2016

Upgrading from 2.1.17 to 2.2.13 is still giving me problems, its turning out to be not that straight forward.
In my java code im using something like the following
select from out('userrole').@Rid, out('userrole').name, name, email from muser
out('userrole').@Rid used to return an array of rids now i just get an array with null!
It works fine in studio, just not when using the java api!
Has something fundamentally changed with respect to using rids? Are we advised not to use rids as keys and generate our own?
This is only a problem when using OSQLAsynchQuery and OSQLNonblockingQuery queries.
It works fine when using the following type of query: database.command(new OCommandSQL(query)).execute()

@luigidellaquila
Copy link
Member

Hi @temilmg

what are you passing to the query as a parameter? a RID, an OClass or a String?

Thanks

Luigi

@temilmg
Copy link
Author

temilmg commented Nov 30, 2016

Hi, I am passing in a String
Thanks for looking into this

@luigidellaquila
Copy link
Member

Ok, this explains everything. A string is not a valid target, eg. if you do the following:

db.query(new OSQLSynchQuery("select @rid,* from ?"), "Foo");

you will obtain the following

SELECT FROM "Foo"

that is not a valid statement of course (or at least it's not what you need).

I think the best thing to do here is support the following:

OClass clazz = db.getMetadata().getSchema().getClass("Foo");
db.query(new OSQLSynchQuery("select @rid,* from ?"), clazz);

Please let me know your thoughts, it's not hard to implement

Thanks

Luigi

@temilmg
Copy link
Author

temilmg commented Nov 30, 2016

No, maybe I didn't explain it correctly my parameter is a string e.g. "#14:0"
and it used to work in 2.1.17
Somewhere i read that I would get the best performance if i did queries like: select from #14:0
So I have used code like: select from ? and then provided rids in the form of strings as parameters
Also I am not using OSQLSynchQuery but OSQLASynchQuery (with the fix of #6267 and hopefully #6946 im trying to move to non blocking queries, but its the same problem)

As for my comment a day ago about "out('userrole').@Rid used to return an array of rids but now returns an array with null " should I create a separate issue?

@luigidellaquila
Copy link
Member

Ah, ok got it, you have to pass it as a RID, eg.

db.query(new OSQLSynchQuery("select @rid,* from ?"), new ORecordId("#12:0"));

It worked in previous versions, but it's not a correct behavior, because a string is not a RID...

Thanks

Luigi

@temilmg
Copy link
Author

temilmg commented Nov 30, 2016

Ok, fair enough!
Thanks

@luigidellaquila
Copy link
Member

Closing then ;-)

Thanks!

Luigi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants