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

EBEDDED[LIST/SET] types and IN/CONTAINS not working? #8428

Closed
hrstoyanov opened this issue Jul 24, 2018 · 9 comments
Closed

EBEDDED[LIST/SET] types and IN/CONTAINS not working? #8428

hrstoyanov opened this issue Jul 24, 2018 · 9 comments
Assignees
Labels
Milestone

Comments

@hrstoyanov
Copy link

OrientDB Version: 3.0.5-SNAPSHOT

Java Version: 8

OS: any

I have this edge definition with ROLES property as an embedded set of strings:

-- Edge that links a staffer to an account.
CREATE CLASS WorksFor extends E,Tracker;
CREATE PROPERTY WorksFor.out     LINK  Account (MANDATORY TRUE, NOTNULL);
CREATE PROPERTY WorksFor.in      LINK Staffer (MANDATORY TRUE, NOTNULL);
CREATE INDEX    WorksFor.out_in ON WorksFor (in,out) UNIQUE;
CREATE PROPERTY WorksFor.roles   EMBEDDEDSET STRING ;
-- [P]ending, [A]ccepted, [R]ejected
CREATE PROPERTY WorksFor.state   STRING (MANDATORY TRUE, DEFAULT "P"); 

and some data:

 >select from WorksFor;

+----+------+--------+-----+-----+-----+---------+
|#   |@RID  |@CLASS  |state|out  |in   |ROLES    |
+----+------+--------+-----+-----+-----+---------+
|0   |#97:0 |WorksFor|A    |#65:0|#89:0|[admin]  |
|1   |#98:0 |WorksFor|A    |#65:0|#90:0|[staffer]|
|2   |#99:0 |WorksFor|A    |#65:0|#91:0|[staffer]|
|3   |#100:0|WorksFor|A    |#65:0|#92:0|[staffer]|
|4   |#101:0|WorksFor|A    |#65:0|#93:0|[viewer] |
|5   |#102:0|WorksFor|R    |#65:0|#94:0|[staffer]|
|6   |#103:0|WorksFor|P    |#65:0|#95:0|[staffer]|
+----+------+--------+-----+-----+-----+---------+

According to this example, I expect that both of these queries would work:

select from WorksFor where 'admin' in roles;
select from WorksFor where roles contains 'admin';

Yet in both cases I get no results ???

@hrstoyanov hrstoyanov reopened this Jul 24, 2018
@hrstoyanov hrstoyanov changed the title [3.0.5] EBEDDEDSET and IN/CONTAINS not working? [3.0.5] EBEDDED[LIST/SET] types and IN/CONTAINS not working? Jul 24, 2018
@hrstoyanov
Copy link
Author

hrstoyanov commented Jul 24, 2018

Ok ... i got to the bottom of this issue: I think console has some lower/upper case defect for properties. Bizarrely, this works:

select from WorksFor where 'admin' in ROLES;
select from WorksFor where 'admin' in ROLES;

If ODB is case sensitive, at least it should respect the exact property name from when the schema was created.

Also, the following returns data:

select from Account where outE(WorksFor).ROLES contains 'admin';

but this does not:

select  from Account where 'admin' in outE(WorksFor).ROLES;

When can the above findings be fixed?

@hrstoyanov hrstoyanov changed the title [3.0.5] EBEDDED[LIST/SET] types and IN/CONTAINS not working? EBEDDED[LIST/SET] types and IN/CONTAINS not working? Jul 24, 2018
@hrstoyanov
Copy link
Author

hrstoyanov commented Jul 26, 2018

These issues are in both console and studio.

@luigidellaquila luigidellaquila self-assigned this Jul 30, 2018
@luigidellaquila
Copy link
Member

Hi @hrstoyanov

I just pushed a fix, it will be released with v 3.0.5

Thanks

Luigi

@luigidellaquila luigidellaquila added this to the 3.0.5 milestone Aug 2, 2018
@hrstoyanov
Copy link
Author

@luigidellaquila
The issue is still here - I see it in 3.0.6-SNAPSHOT. Are you sure you merged the fix upstream?

These queries works:

select from WorksFor where  ROLES contains 'admin';
select from WorksFor where  'admin' in ROLES;

but the below ones do not work:

select from WorksFor where  roles contains 'admin';
select from WorksFor where  'admin' in roles;

I have not tested in 3.0.5 final

@hrstoyanov
Copy link
Author

@luigidellaquila
do you need sample database/data for this?

@luigidellaquila
Copy link
Member

Hi @hrstoyanov

Yes, I merged it. If you have a sample DB it will help a lot, there is a chance that I didn't get exactly your use case

Thanks

Luigi

@hrstoyanov
Copy link
Author

hrstoyanov commented Aug 6, 2018

@luigidellaquila find attached a sample database. Run: schema, seed_data, test_data. Then the above queries should show you the problem.

@luigidellaquila
Copy link
Member

Hi @hrstoyanov

Thank you very much, now everything is clear.
In OrientDB v 3.0 property names ARE case sensitive indeed (see https://orientdb.com/docs/3.0.x/release/3.0/Upgrading-to-OrientDB-3.0.html), so ROLES is different from roles.
That means that the following is legitimate and correct:

INSERT INTO Person SET name = 'foo', NAME = 'bar'

and NAME and name are stored as two different properties. This is why your query is returning no results and this is why it is also correct that the engine does not complain when you insert properties with a different case.

This said, I'm afraid we cannot do much about this behavior, as it is the expected one

Thanks

Luigi

@hrstoyanov
Copy link
Author

Got it! Closing this issue..

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