无法在 COALESCE pypher 中设置列​​表类型值

Unable to set list type value in COALESCE pypher

我想通过 pypher 构建查询

set entity.birth_date = coalesce(VALUE + entity.birth_date, entity.birth_date , [] + VALUE)

VALUE 是类似于“38”的字符串

我试过的是:

from pypher import Pypher, __
p = Pypher()
p.Merge.node('ent', **node_gr)
p.SET(__.ent.__birth_place__ == __.COALESCE(__.ent.__birth_place__+ 
VALUE,__.ent.__birth_place__,[VALUE]))

它抛出以下错误:

python3.6/site-packages/pypher/builder.py in bind_param(self, value, name)
    196                     name = k
    197                     break
--> 198         elif bind and value in self._bound_params.keys():
    199             for k, v in self._bound_params.items():
    200                 if k == value:

TypeError: unhashable type: 'list'

我也试过将 [VALUE] 转换为字符串,但更新后的值不正确,因为字符串

Pypher 提供了 __.List 函数来从一个值构造一个列表。例如,以下内容:

p.SET(__.ent.__birth_place__ == __.COALESCE(__.ent.__birth_place__ + VALUE,__.ent.__birth_place__, __.List() + VALUE))

产生类似于:

MERGE (ent:`MyNode`) SET ent.`birth_place` = coalesce(ent.`birth_place` + $NEO_5288d_0, ent.`birth_place`, [] + $NEO_5288d_0)

尽管由于 List 接受一个参数让您构建一个列表,更好的方法可能是:

p.SET(__.ent.__birth_place__ == __.COALESCE(__.ent.__birth_place__ + VALUE,__.ent.__birth_place__, __.List(VALUE)))

产生类似的东西:

MERGE (ent:`MyNode`) SET ent.`birth_place` = coalesce(ent.`birth_place` + $NEO_e2895_0, ent.`birth_place`, [$NEO_e2895_0])