执行CREATE查询时,我收到与双向关系有关的错误。

huangapple go评论51阅读模式
英文:

When executing the CREATE query I get the error about Bidirectional relationship

问题

执行查询CREATE (h:Human)-[l:LOVES]-(f:Foof) RETURN h, l, f;时,我收到以下错误:

错误: 查询失败: 在创建边时不支持双向关系 

如果我使用MERGE而不是CREATE,则关系会被创建:

MERGE (h:Human)-[l:LOVES]-(f:Foof) RETURN h, l, f

为什么会这样?

英文:

When I execute the query CREATE (h:Human)-[l:LOVES]-(f:Foof) RETURN h, l, f;, I get the following error:

Error: Query failed: Bidirectional relationship are not supported when creating an edge

If I use MERGE instead of CREATE, the relationship is created:

MERGE (h:Human)-[l:LOVES]-(f:Foof) RETURN h, l, f

Why is this so?

答案1

得分: 0

假设Memgraph遵循openCypher规范,对于没有指定方向的MERGE,规范允许实现选择一个方向。虽然这意味着查询可以工作,但提供一个明确的边方向会更好(也更安全)。

具体的指导信息在上面链接的文档的第119页上给出,其中指出:

MERGE也可以与无方向的关系一起使用。当需要创建一个新的关系时,它将选择一个方向。

英文:

Assuming that Memgraph is following the openCypher specification, for a MERGE where no direction is specified, the spec allows the implementation to pick a direction. While this means the query will work, it's going to be better (and safer) to provide an explicit edge direction.

The specific guidance is given on Page 119 of the document linked above, where it states:

>MERGE can also be used with an undirected relationship. When it needs to create a new one, it will
pick a direction.

huangapple
  • 本文由 发表于 2023年2月24日 01:50:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75548537.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定