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

UNIQUE DATETIME index on edge not enforced #3799

Closed
TheDefinitiveMilton opened this issue Mar 24, 2015 · 2 comments
Closed

UNIQUE DATETIME index on edge not enforced #3799

TheDefinitiveMilton opened this issue Mar 24, 2015 · 2 comments
Assignees
Milestone

Comments

@TheDefinitiveMilton
Copy link

orientdb-community-2.0.5
CentOS 6.5

Unique indexes on edges on a datetime are not being enforced, and the issue can be replicated using the following test case:

create class test extends V
create property test.test string
create index idx_test_test on test (test) unique

create vertex test content {"test": "test"}
create vertex test content {"test": "test2"}

create class test_edge extends E
create property test_edge.date datetime
create index idx_unique_test_edge on test_edge (date) unique

create edge test_edge from (select from test where test = 'test') to (select from test where test = 'test2') content {"date": "2015-03-24 08:54:49"}
create edge test_edge from (select from test where test = 'test') to (select from test where test = 'test2') content {"date": "2015-03-24 08:54:49"}

In the above example, the two edges are successfully created with the same date, violating the unique index idx_unique_test_edge:

orientdb {db=test3}> select from test_edge 

----+-----+---------+-------------------+-----+-----
#   |@RID |@CLASS   |date               |out  |in   
----+-----+---------+-------------------+-----+-----
0   |#13:0|test_edge|2015-03-24 08:54:49|#12:0|#12:1
1   |#13:1|test_edge|2015-03-24 08:54:49|#12:0|#12:1
----+-----+---------+-------------------+-----+-----

However, if I create a new edge class using string instead of datetime, the index works correctly:

create class test_edge2 extends E
create property test_edge2.date string 
create index idx_unique_test_edge2 on test_edge2 (date) unique

create edge test_edge2 from (select from test where test = 'test') to (select from test where test = 'test2') content {"date": "2015-03-24 08:54:49"}
create edge test_edge2 from (select from test where test = 'test') to (select from test where test = 'test2') content {"date": "2015-03-24 08:54:49"}

The second command results in a duplicate exception:

Error: com.orientechnologies.orient.core.storage.ORecordDuplicatedException: Cannot index record #14:1: found duplicated key 'OCompositeKey{keys=[#12:1, #12:0, 2015-03-24 08:54:49]}' in index 'idx_unique_test_edge2' previously assigned to the record #14:0 RID=#14:0
@machak
Copy link

machak commented Mar 25, 2015

for some reason index is not used at all (first example). If you try java code, it just works TM
see for example:
select expand(indexes) from metadata:indexmanager

and try to run:

rebuild index *

it will throw exception:
Rebuilding index(es)...
Error: com.orientechnologies.orient.core.index.OIndexException: Error on rebuilding the index for clusters: [test_edge]

Error: com.orientechnologies.orient.core.storage.ORecordDuplicatedException: Cannot index record #14:1: found duplicated key 'Tue Mar 24 08:54:49 CET 2015' in index 'idx_unique_test_edge' previously assigned to the record #14:0 RID=#14:0

@lvca lvca added this to the 2.0.6 milestone Mar 25, 2015
@lvca lvca added the bug label Mar 25, 2015
@lvca lvca modified the milestones: 2.0.6, 2.0.7 Mar 31, 2015
tglman added a commit that referenced this issue Mar 31, 2015
Conflicts:
	core/src/main/java/com/orientechnologies/orient/core/record/impl/ODocument.java
@tglman
Copy link
Member

tglman commented Mar 31, 2015

fixed closing.

@tglman tglman closed this as completed Mar 31, 2015
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

4 participants