Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set "list" in as property value #31

Closed
gb08 opened this issue Sep 17, 2019 · 2 comments
Closed

Cannot set "list" in as property value #31

gb08 opened this issue Sep 17, 2019 · 2 comments

Comments

@gb08
Copy link

gb08 commented Sep 17, 2019

unable to build cypher query to set "list" type value in property.
set entity.birth_date = coalesce(VALUE + entity.birth_date, entity.birth_date , [] + VALUE)

What I've tried:
from pypher import Pypher, __
p = Pypher()
node_gr = dict()
node_gr['name'] = 'XYZ'
p.Merge.node('ent', **node_gr)
p.SET(__.ent.__birth_place__ == __.COALESCE(__.ent.__birth_place__+
VALUE,__.ent.__birth_place__,[VALUE]))

Error:
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'

@emehrkay
Copy link
Owner

emehrkay commented Oct 7, 2019

This slipped under my radar. Did you want the brackets to show up in the resulting Cypher? If so, use the List class:

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

str(p) 
# MERGE (ent {`name`: $nameb5401_0}) SET ent.`birth_place` = coalesce(ent.`birth_place` + $NEO_b5401_1, ent.`birth_place`,  [$NEO_b5401_1])
# {'NEO_b5401_1': 123, 'nameb5401_0': 'XYZ'}

@gb08
Copy link
Author

gb08 commented Nov 30, 2019

Yes, Thank you!

What if I want to set property with list as a value.
p.SET(__.ent.xyz == var1)

where var1 = ['a', 'b'] (var1 is already in list python format)

@emehrkay emehrkay closed this as completed Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants