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

Query returns incorrect results #7271

Closed
alpeshgaglani opened this issue Mar 26, 2017 · 4 comments
Closed

Query returns incorrect results #7271

alpeshgaglani opened this issue Mar 26, 2017 · 4 comments
Assignees
Labels

Comments

@alpeshgaglani
Copy link

OrientDB Version: 2.2.17

Our database returns wrong results for the following query:
select expand($courses) from Activity let courses = (select from $current.in_ContainsActivity.out) where id = 809
The query returns a record with the class "Course", and id = 67

However, if you follow the in_ContainsActivity.out link from Activity where id = 809, the record that should be returned has id = 54

I've uploaded an export of our test database where this issue occurs:
https://drive.google.com/file/d/0B_TS9oS4-Fi2UDh4b0VxbU1NbHc/view?usp=sharing

@alpeshgaglani
Copy link
Author

Any updates on this issue? It's really hurting us right now.

@luigidellaquila
Copy link
Member

Hi @alpeshgaglani

I'm not sure I got the point of your query... That $current refers to records in the subquery, not in the parent query. The right syntax should be:

select expand($courses) from Activity let courses = (select from $parent.$current.in_ContainsActivity.out) where id = 809

But why should you use that? Can't you just do

select expand(in_ContainsActivity.out) from Activity where id = 809

or even better

select expand(in("ContainsActivity")) from Activity where id = 809

Thanks

Luigi

@alpeshgaglani
Copy link
Author

Thanks @luigidellaquila for the response. Our understanding was that in this particular case, $current refers to the current record set in the top level query. Interestingly, this used match exactly with our understanding up until 2.1.x! We have to use projection because we are doing further sub queries. I had just posted the simplified query to help debugging :)
👍 for your help!

@luigidellaquila
Copy link
Member

HI @alpeshgaglani

Just to give you all the info, $current variable refers to the current record in current (sub) query. If you want to access the parent query context you can use $parent variable, eg. $parent.$current refers to the current record in parent query. You can also use it at multiple levels, eg. $parent.$parent.$current.

I guess I can close this issue, please reopen if you need further help

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

2 participants