I have no idea how to set LINKMAP at the first time.
Is there concat function as "||" for MAP types?
CREATE CLASS Test;
CREATE CLASS TestMap;
CREATE PROPERTY Test.mymap LINKMAP TestMap;
CREATE PROPERTY Test.id STRING;
INSERT INTO TestMap (name) VALUES ('test');
INSERT INTO Test SET id = "123";
0. UPDATE Test SET mymap['A-1'] = (SELECT FROM TestMap WHERE name = 'test') WHERE id = "123"
// java.lang.NullPointerException
1. UPDATE Test SET mymap = {'A-1': (SELECT FROM TestMap WHERE name = 'test')} WHERE id = "123"
// {"A-1": #x:x}
2. UPDATE Test SET mymap['A-2'] = (SELECT FROM TestMap WHERE name = 'test') WHERE id = "123"
// {"A-1": #x:x, "A-2": #x:x}
The problem is I can't predict order of sql 1 and 2. I tried to do something like
INSERT INTO Test SET id = "123", mymap = {"dummy": -1:-1}
// com.orientechnologies.orient.core.exception.OValidationException: The field 'Test.mymap' has been declared as LINKMAP but contains a null record (probably a deleted record?)
hi @freeart
I'd say the NullPointerException in the first case is a bug, it is supposed to work exactly the same as case 2.
I'll check it ASAP
In the meantime, you can try to initialize it as an empty map:
INSERT INTO Test SET id = "123", mymap = {}
Thanks
Luigi
Hi @freeart
I also pushed a fix for the ugly NullPointer
Thanks
Luigi
Most helpful comment
hi @freeart
I'd say the NullPointerException in the first case is a bug, it is supposed to work exactly the same as case 2.
I'll check it ASAP
In the meantime, you can try to initialize it as an empty map:
Thanks
Luigi