简体   繁体   English

在Neo4j中用Cypher设置null值

[英]Set null value with Cypher in Neo4j

I am trying to set a null value for a property when I create a node.我试图在创建节点时为属性设置 null 值。

I tried something like this:我试过这样的事情:

CREATE(p:Person {p_id: TOINT(line.`id`) })
SET p.initials = null

But that gives me Neo.ClientError.Statement.SyntaxError .但这给了我Neo.ClientError.Statement.SyntaxError

How can I set a null value with CQL in Neo4j?如何在 Neo4j 中使用 CQL 设置 null 值?

I don't think that you error comes from setting a property to null, but on the TOINT function. 我不认为您的错误来自将属性设置为null,而是在TOINT函数上。 Cypher is case-sensitive, and the correct syntax is toInt. Cypher区分大小写,正确的语法是toInt。 So your query should looks like this : 所以你的查询应该是这样的:

CREATE(p:Person {p_id: toInt(line.`id`) })
SET p.initials = null

Moreover, Neo4j doesn't store null value. 而且,Neo4j不存储null值。 A null value, is a property that doesn't exist. null值是一个不存在的属性。

In Neo4j you can't set null to property that way.在 Neo4j 中,您不能以这种方式将 null 设置为属性。 But to get the same result you can remove the property for the given node.但是要获得相同的结果,您可以删除给定节点的属性。 You can learn more about removing properties in neo4j docs您可以在neo4j 文档中了解有关删除属性的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM