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

when property with type "linklist" have attribute "LINKEDCLASS" then it is impossible to keep an array with "null" values #4686

Closed
habi4ek opened this issue Jul 30, 2015 · 3 comments
Assignees
Labels

Comments

@habi4ek
Copy link

habi4ek commented Jul 30, 2015

Hi
I use OrientDB Server v2.0.13

when I use property without "LINKEDCLASS" I can save this record

[#5:0,null,#5:0]

orientdb {db=test}> create class testl extends V
Class created successfully. Total classes in database now: 13

orientdb {db=test}> create property testl.list linklist
Property created successfully with id=1

orientdb {db=test}> insert into testl set list = [#5:0,null,#5:0]
Inserted record 'testl#13:0{list:[3]} v1' in 0,017000 sec(s).

orientdb {db=test}> select list.size() from #13:0
----+------+----

| @ CLASS|list

----+------+----
0 |null |3
----+------+----
1 item(s) found. Query executed in 0.002 sec(s).

orientdb {db=test}> insert into testl content {"list":["#5:0",null,"#5:0"]}
Inserted record 'testl#13:1{list:[3]} v1' in 0,017000 sec(s).

orientdb {db=test}> select list.size() from #13:1
----+------+----

| @ CLASS|list

----+------+----
0 |null |3
----+------+----
1 item(s) found. Query executed in 0.002 sec(s).

but if I set attribute "LINKEDCLASS" record doesn't save

orientdb {db=test}> create class test2 extends V
Class created successfully. Total classes in database now: 14

orientdb {db=test}> create property test2.list linklist
Property created successfully with id=1

orientdb {db=test}> alter property test2.list linkedclass OUser
Property updated successfully

orientdb {db=test}> insert into test2 set list = [#5:0,null,#5:0]
Error: com.orientechnologies.orient.core.exception.OValidationException: The field 'test2.list' has been declared as LINKLIST but contains a null record (probably a deleted record?)

orientdb {db=test}> insert into test2 content {"list":["#5:0",null,"#5:0"]}
Error: com.orientechnologies.orient.core.exception.OValidationException: The field 'test2.list' has been declared as LINKLIST but contains a null record (probably a deleted record?)

Recorded data is possible if we replace "null" on "#-1:-1"

orientdb {db=test}> insert into test2 set list = [#5:0,#-1:-1,#5:0]
Inserted record 'test2#14:0{list:[3]} v1' in 0,004000 sec(s).

orientdb {db=test}> select list.size() from #14:0
----+------+----

| @ CLASS|list

----+------+----
0 |null |3
----+------+----
1 item(s) found. Query executed in 0.002 sec(s).

orientdb {db=test}> insert into test2 content {"list":["#5:0","#-1:-1","#5:0"]}
Inserted record 'test2#14:1{list:[3]} v1' in 0,002000 sec(s).

orientdb {db=test}> select list.size() from #14:1
----+------+----

| @ CLASS|list

----+------+----
0 |null |3
----+------+----
1 item(s) found. Query executed in 0.002 sec(s).

@nagarajasr
Copy link
Contributor

what does it mean to insert a null value in list, when having a linked class? i think it is invalid.
however, you should be able to use ifnull() function (http://orientdb.com/docs/last/SQL-Functions.html#ifnull) to replace null values with #-1:-1 if you really need to handle this situation

@habi4ek
Copy link
Author

habi4ek commented Jul 30, 2015

sometimes I need insert array with null values because length of an array is important for me
and I want to get back an array of the same length as the insert

when I insert record [#-1:-1,#5:0] that DB returns [null,#5:0]. it is OK for me
why I cannot insert record [null,#5:0] at once

@habi4ek habi4ek closed this as completed Jul 30, 2015
@habi4ek
Copy link
Author

habi4ek commented Jul 31, 2015

sorry, example above returns array [#5:0] without "null".

DB always cuts first "null" when returning the result
but inside DB record is correct
select list.size() from "this record" => 2

even if I insert [#-1:-1,#-1:-1,#-1:-1,#5:0], DB cuts only first null.
And result query (select from "this record" ) will be [null,null,#5:0]
but if I insert [#5:0,#-1:-1,#5:0] , DB returns correct result [#5:0,null,#5:0]

@habi4ek habi4ek reopened this Jul 31, 2015
@lvca lvca added this to the 2.0.14 milestone Jul 31, 2015
@lvca lvca modified the milestones: 2.0.14, 2.0.15 Aug 10, 2015
@lvca lvca modified the milestones: 2.0.15, 2.2 Aug 26, 2015
@lvca lvca added the bug label Sep 21, 2015
@lvca lvca modified the milestones: 2.2.0-beta, 2.2.0-rc1 Dec 13, 2015
@lvca lvca modified the milestones: 2.2.0-rc1, 2.2.0 GA May 7, 2016
@robfrank robfrank modified the milestones: 2.2.0 GA, 2.2.1 May 18, 2016
@robfrank robfrank modified the milestones: 2.2.1, 2.2.x (next hotfix) Jun 8, 2016
@robfrank robfrank modified the milestones: 2.2.x (next hotfix), 2.2.1 Jun 8, 2016
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

6 participants