OrientDB 3.0.4 Console EMBEDDEDLIST CREATE VERTEX

て烟熏妆下的殇ゞ 提交于 2019-12-24 23:14:40

问题


It appears that console application in OrientDB 3.0.4 is not backward compatible with OrientDB 3.0.2 for creating Vertex having EMBEDDEDLIST.

Following Query fails in OrientDB 3.0.4 console:

 CREATE VERTEX Profile SET name = "John", phone = [{ "@type":"d", "number" : "212" }]

How can I resolve the issue? What are the changes for v3.0.4 and where can I find updated documentation?


OrientDB console v.3.0.2 - Veloce (build e47e693f1470a7a642461be26983d4eca70777fd, branch develop)


    OrientDB console v.3.0.2 - Veloce (build e47e693f1470a7a642461be26983d4eca70777fd, branch develop) https://www.orientdb.com
    Type 'help' to display all the supported commands.
    orientdb> create database remote:localhost/mydb root orientdb

    Creating database [remote:localhost/mydb] using the storage type [PLOCAL]...
    Database created successfully.

    Current database is: remote:localhost/mydb
    orientdb {db=mydb}> create class Phone EXTENDS V

    Class created successfully.

    orientdb {db=mydb}> create property Phone.number String

    Property created successfully.

    orientdb {db=mydb}> create class Profile EXTENDS V

    Class created successfully.

    orientdb {db=mydb}> create property Profile.name String

    Property created successfully.

    orientdb {db=mydb}> create property Profile.phone embeddedList Phone

    Property created successfully.

    orientdb {db=mydb}> CREATE VERTEX Profile SET name = "John", phone = [{ "@type":"d", "number" : "212" }]

    Created vertex '[Profile#33:0{name:John,phone:[1]} v1]' in 0.023000 sec(s).

-------

OrientDB console v.3.0.4 - Veloce (build 4578b51f72a55feaa0852bc8ddd52929011d956c, branch 3.0.x)


    OrientDB console v.3.0.4 - Veloce (build 4578b51f72a55feaa0852bc8ddd52929011d956c, branch 3.0.x) https://www.orientdb.com
    Type 'help' to display all the supported commands.
    orientdb> create database remote:localhost/mydb root orientdb

    Creating database [remote:localhost/mydb] using the storage type [PLOCAL]...
    Database created successfully.

    Current database is: remote:localhost/mydb

    orientdb {db=mydb}> create class Phone EXTENDS V

    Class created successfully.

    orientdb {db=mydb}> create property Phone.number String

    Property created successfully.

    orientdb {db=mydb}> create class Profile EXTENDS V

    Class created successfully.

    orientdb {db=mydb}> create property Profile.name String

    Property created successfully.

    orientdb {db=mydb}> create property Profile.phone embeddedList Phone

    Property created successfully.

    orientdb {db=mydb}> CREATE VERTEX Profile SET name = "John", phone = [{ "@type":"d", "number" : "212" }]

    Error: com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error parsing query:
    create VERTEX Profile SET name = "John", phone = [{ "@type":"d", "number" : "212" }
                                                     ^
    Encountered " "[" "[ "" at line 1, column 50.
    Was expecting one of:
         ...
         ...
         ...
        "{" ...
         ...
         ...
         ...
        "{" ...
        "{" ...
         ...
         ...
         ...
        "{" ...
        "{" ...
        "{" ...
         ...
         ...
         ...
        "{" ...
        "{" ...
         ...
         ...
         ...
        "{" ...
        "{" ...
         ...
         ...
         ...
        "{" ...
        "{" ...
        "{" ...

        DB name="mydb"
        Error Code="1"
        DB name="mydb"

    !Unrecognized command: ']'
    orientdb {db=mydb}> 


回答1:


The issue is that you've declared your property as "Phone" and then you're trying to create your vertex using the name "phone" in lowercase which doesn't match the schema. Also there's no need to use square brackets so instead of that last query, try using:

CREATE VERTEX Profile SET name = "John", Phone = { "@type":"d", "number" : "212"}


来源:https://stackoverflow.com/questions/51328840/orientdb-3-0-4-console-embeddedlist-create-vertex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!