-
Notifications
You must be signed in to change notification settings - Fork 80
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
feature: .union() & .union_all() query clause methods #309
base: master
Are you sure you want to change the base?
Conversation
1 similar comment
|
||
# If `value` is a query object, returns value.to_cypher. Formatting optional | ||
def from_query(value, pretty: false) | ||
from_string(value.to_cypher(pretty: pretty)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember seeing other uses of KW args in the neo4j-core source. I'm not sure if this was personal preference or if you're targeting a version of Ruby pre-KW args
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right that they aren't used much. In the past we've supported Ruby 1.9, but we require at least Ruby 2.1 now, so keyword arguments should be fine.
Also: this should probably be updated so that if |
What happens if you make a new I'm a bit worried about the added complexity (to an already really complex pair of classes).
|
This PR follows what I proposed over in #308. Namely:
This implementation doesn't attempt to validate the columns. Instead, the recommended usage is to pass in a query object as the argument to the union clause and then The modified
I'm not sure how this would be different from adding a |
Just my 2 sense. I've read from #308 until here, and I perceive unnecessary discrepancies for "union_all". There are use cases for this, and it is most beneficial when wanting the database engine to do work before retrieving results. The syntax is not confusing, and in fact, is much easier to use with the neo4jrb framework. Create 2 queries , q1 and q2
What am I missing ? UPDATE: As in, it is up to the query writer to make sure that the result of both queries return similarly structured nodes. The single resultset that the engine returns should be proxied just as per a single query (as there is 1 resultset) https://neo4j.com/docs/developer-manual/current/cypher/clauses/union/ |
Would be great if I could at the very least do And a QueryProxy of MyObj were returned. (or an array - I guess why you mentioned to do pluck_union) UPDATE: Yes, I realise that https://github.com/neo4jrb/neo4j would be responsible for the QueryProxy part of it |
@tjad I stopped pushing forward with this because At the moment, if you want to perform a union query, you'll need to either use the existing |
Fixes #308
Currently, both
.union()
and.union_all()
are working for my (limited) testing.I wanted to run my implementation by you before writing any tests / docs. You were correct, the query clause method implementation is rather confusing.
query.union_all(query)
adds aUNION ALL
clausequery.union(query)
adds aUNION
clauseYou can pass either a query object or a string to union / union_all.
Some added benefits come if you use a query object for the union clause's argument:
.pluck()
ing the base query object will overwrite thereturn
of the union clausePings:
@cheerfulstoic
@subvertallchris