emehrkay / Pypher

Python Cypher Querybuilder
MIT License
164 stars 29 forks source link

IN statement doesn't produce correct output when combined with partial statement returning a list #55

Open BenedictBoyle opened 1 year ago

BenedictBoyle commented 1 year ago

I want to write something like:

p1 = Pypher()
p2 = Pypher()
p2.split(<some input>, ",")
p1.IN(p2)

But the way the class IN(Statement) is defined means that this will come out unnecessarily wrapped in square braces and the cypher engine will fall over when it gets a list of lists.

I think this could be fixed by adding some logic to the class definition of IN and am happy to do the work over the weekend to raise a PR but wondered if you had a preference for how to fix given you know + understand the codebase far better than me? I would do something like checking if the partial statement contains a split() or collect() but I feel like there's a lot of scope for missing cases there and seems not very elegant.

Also possible I've misunderstood how to make a partial properly and there's a way to do what I want without changing the code.

emehrkay commented 1 year ago

This is a good catch. I would definitely welcome your fix when you have time. Thanks