Orientdb: How to initialise MAP type at the first time

Created on 14 Nov 2018  路  2Comments  路  Source: orientechnologies/orientdb

OrientDB Version: 3.1.0 from develop branch

Java Version: docker openjdk:8-jdk-alpine

OS: docker openjdk:8-jdk-alpine

I have no idea how to set LINKMAP at the first time.
Is there concat function as "||" for MAP types?

Steps to reproduce

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?)
bug question

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:

INSERT INTO Test SET id = "123", mymap = {}

Thanks

Luigi

All 2 comments

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

Was this page helpful?
0 / 5 - 0 ratings