-
Couldn't load subscription status.
- Fork 78
Description
While attempting to create a query involving the union of three sub-queries, I discovered that union_cypher expects a query object but returns a string rather than another query object. This prevents me from performing a union query on a union query. Given that all the other query methods return a query object, is there a reason for this behavior? I guess it kinda explains the name union_cypher
neo4j-core/lib/neo4j-core/query.rb
Lines 376 to 386 in 00190f4
| # @example | |
| # # Generates cypher: MATCH (n:Person) UNION MATCH (o:Person) WHERE o.age = 10 | |
| # q = Neo4j::Core::Query.new.match(o: :Person).where(o: {age: 10}) | |
| # result = Neo4j::Core::Query.new.match(n: :Person).union_cypher(q) | |
| # | |
| # @param other [Query] Second half of UNION | |
| # @param options [Hash] Specify {all: true} to use UNION ALL | |
| # @return [String] Resulting UNION cypher query string | |
| def union_cypher(other, options = {}) | |
| "#{to_cypher} UNION#{options[:all] ? ' ALL' : ''} #{other.to_cypher}" | |
| end |
How would you feel about a PR to either create a new query method union that returns another query object for further chaining?
Alternatively (and easier to implement), union_cypher could be updated so that it tests to see if its argument is already a string and, if so, simply inserts it without first calling to_cypher on the argument.
Thoughts?