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

Strange logic for filtering against linkset properties #8956

Closed
creisle opened this issue Jul 13, 2019 · 3 comments
Closed

Strange logic for filtering against linkset properties #8956

creisle opened this issue Jul 13, 2019 · 3 comments

Comments

@creisle
Copy link

creisle commented Jul 13, 2019

OrientDB Version: 3.0.20

Java Version:

openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

OS: centos7

Expected behavior

For the = operator I expected it to check against the whole set.
For the contains operator I expected either that this would not work, or that it would check as a subset operation? or that it would check that the two iterables had common elements.

Actual behavior

It doesn't seem to do any of these consistently

Steps to reproduce

start with the demo db

create class testLinkSet extends V
create property hasCastles linkset Castles
create vertex testLinkSet set hasCastles = [#152:0 , #152:1]
create vertex testLinkSet set hasCastles = [#152:0, #152:3, #152:1]
create vertex testLinkSet set hasCastles = [#152:0, #152:3, #152:1]
create vertex testLinkSet set hasCastles = [#152:0, #152:4, #152:1]

I tried to use intersect to verify something i expected to work. I thought this would return all links since they are all classes

select * from statement where intersect(hasCastles, (select * from castles)).size() > 0```

but it returns nothing

next I tried using the contains operator. this works for a single element in a list or the element not in a list

```sql
select * from statement where hasCastles contains [152:0]
select * from statement where hasCastles contains 152:0
select * from statement where hasCastles = [152:0]
select * from statement where hasCastles = 152:0

but fails (returns nothing) when there are two

select * from statement where hasCastles contains [152:0, 152:1]

Is there a valid way to check if some linkset has records in common with a subquery? perhaps a containsany operator or some such?

@luigidellaquila
Copy link
Member

Hi @creisle

CONTAINS operator only checks if a single element is contained in a collection. If you need more complex logic, you can use CONTAINSALL (checks that all the elements on the right are contained in the collection on the left) or CONTAINSANY (checks that at least one of the elements on the right is contained in the collection on the left)

I hope it helps

Thanks

Luigi

@creisle
Copy link
Author

creisle commented Jul 15, 2019

Thanks @luigidellaquila the containsany operator isn't listed in the docs so I wasn't aware of it

http://orientdb.com/docs/3.0.x/sql/SQL-Where.html

That does seem to work!

@creisle creisle closed this as completed Jul 15, 2019
@creisle
Copy link
Author

creisle commented Jul 18, 2019

I opened a ticket for adding this documentation here orientechnologies/orientdb-docs#351

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

2 participants