javascriptorientdborientjs

Unable to create EDGE in Orientjs


I'm working with OrientJS and I am trying to create an edge between two nodes. Until some days ago, all worked fine with the script below:

module.exports.insertRelatedToAssociation = (nodeFrom, nodeTo) => {
    db.create('EDGE', 'RelatedTo')
        .from(nodeFrom).to(nodeTo)
        .one()
        .then(function (result) {
             return (result !== undefined)
         })     
}

But now, I suddenly receive this error message everytime I run the script:

com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error parsing query:
CREATE EDGE RelatedTo FROM #29:5
     ^
Encountered " <CREATE> "CREATE "" at line 1, column 1.
Was expecting one of:
    <SELECT> ...
    <TRAVERSE> ...
    <MATCH> ...
    <INSERT> ...
    <RETURN> ...
    <PROFILE> ...
    <FIND> ...
    <REBUILD> ...
    <OPTIMIZE> ...
    <GRANT> ...
    <REVOKE> ...
    <BEGIN> ...
    <COMMIT> ...
    <ROLLBACK> ...
    <IF> ...
    <SLEEP> ...
    <CONSOLE> ...

    DB name="test-graph"
    at com.orientechnologies.orient.core.sql.parser.OStatementCache.throwParsingException(OStatementCache.java:109)
    at com.orientechnologies.orient.core.sql.parser.OStatementCache.parse(OStatementCache.java:103)
    at com.orientechnologies.orient.core.sql.parser.OStatementCache.get(OStatementCache.java:81)
    at com.orientechnologies.orient.core.sql.parser.OStatementCache.get(OStatementCache.java:64)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLAbstract.preParse(OCommandExecutorSQLAbstract.java:232)
    at com.orientechnologies.orient.graph.sql.OCommandExecutorSQLCreateEdge.parse(OCommandExecutorSQLCreateEdge.java:66)
    at com.orientechnologies.orient.graph.sql.OCommandExecutorSQLCreateEdge.parse(OCommandExecutorSQLCreateEdge.java:46)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.parse(OCommandExecutorSQLDelegate.java:58)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.parse(OCommandExecutorSQLDelegate.java:39)
    at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.command(OAbstractPaginatedStorage.java:3144)
    at com.orientechnologies.orient.core.command.OCommandRequestTextAbstract.execute(OCommandRequestTextAbstract.java:69)
    at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.command(ONetworkProtocolBinary.java:1529)
    at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.executeRequest(ONetworkProtocolBinary.java:646)
    at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.sessionRequest(ONetworkProtocolBinary.java:384)
    at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.execute(ONetworkProtocolBinary.java:207)
    at com.orientechnologies.common.thread.OSoftThread.run(OSoftThread.java:77)

Maybe, OrientDB changed its parser, but I found nothing about it on the GitHub Wiki (https://github.com/orientechnologies/orientdb/wiki/OrientDB-2.2-Release-Notes#2226---august-16-2017).

Note: I am running the orientdb-community-importers-2.2.24. The same is with the version 2.2.26.


Solution

  • I found the error. It simply was that the parameter nodeFrom was undefined. So passing undefined to db.create('EDGE','RelatedTo).from(undefined).to(nodeTo) produce that error!