emehrkay / Pypher

Python Cypher Querybuilder
MIT License
165 stars 29 forks source link

SET a dict #5

Closed g3rd closed 6 years ago

g3rd commented 6 years ago

Hello,

First off, thanks for this project. I started to write one today. Then stumbled upon this, and stopped mine.

How would I write:

CREATE (u:User) SET u = {props};

or

MATCH (u:User {username: {username}}) SET u += {props};

Thanks again!

emehrkay commented 6 years ago

Great catch. This was something that I was meaning to implement, but has completely feel off of my radar.

It would be pretty easy to add support for setting a dict in python and returning the curly brace-structure in cypher. However, I remember seeing an example that looked something like RETURN {.name} and I not too sure how to handle it.

If we start with something like:

p.SET.u += {'name': 'some name', 'age' 999}

What does that look like in cypher? Is it SET u += {'name': $name_var, 'age': $age_var} or something different? And what are the other permutations of that dict-like structure in cypher that we'd need to account for in python?

It isn't too difficult to add, I just want to make sure we get it right. I will check the documentation for more examples. Please drop some links if you have any.

Thanks

Edit: I found the map projections page in the documentation. I will work on adding this: https://neo4j.com/docs/developer-manual/current/cypher/syntax/maps/

g3rd commented 6 years ago

The two examples above I currently write out by hand and then run through the neo4j-driver

emehrkay commented 6 years ago

I'll have updates for full map support tonight. Both in setting a node/relationship's properties and other usage in Cypher queries.

emehrkay commented 6 years ago

This latest release should be what you're looking for.

https://github.com/emehrkay/Pypher#operators

I'm going to push to pypi soon

emehrkay commented 6 years ago

Addressed with version 0.7.0

g3rd commented 6 years ago

@emehrkay thanks!