neo4j-core
neo4j-core copied to clipboard
Query `clauses` and `@arg` should be exposed to the public API
I'm finding myself in need of inspecting qualities of queries pretty often but the internals are part of private or protected APIs. To get around it, I'm using send
and instance_variable_get
but it's dangerous, so I'd like to move these to the public API. Any objections?
Can you share a use case or two (mainly out of curiosity)?
I keep running into cases where I want to use the presence or lack of query clauses and values to modify a query in some way. "If the query contains this clause and its args are or contain this value/key/string/whatever, take this action." The "clause?" method gets us part of the way there but actually looking at the clause object and seeing its arguments, not the String version you get when calling "values," isn't possible without reaching for methods that are walled off.
On Tuesday, May 5, 2015, Brian Underwood [email protected] wrote:
Can you share a use case or two (mainly out of curiosity)?
— Reply to this email directly or view it on GitHub https://github.com/neo4jrb/neo4j-core/issues/196#issuecomment-99272943.
Do you have a specific use case? I'm curious because I haven't run across a need for this when using ActiveRecord (doesn't mean it's not needed ;)
Yes, I did exactly this while implementing "limit_value" in the other gem yesterday.
On Wednesday, May 6, 2015, Brian Underwood [email protected] wrote:
Do you have a specific use case? I'm curious because I haven't run across a need for this when using ActiveRecord (doesn't mean it's not needed ;)
— Reply to this email directly or view it on GitHub https://github.com/neo4jrb/neo4j-core/issues/196#issuecomment-99389611.
"limit_value" is an ActiveRecord thing that a gem I'm porting over needed. Within the same gem, I had to figure out if "order" had been called and then, if so, return a different value if "desc" was used. "clause?" can take care of the first part but not the second.
On Wednesday, May 6, 2015, Chris Grigg [email protected] wrote:
Yes, I did exactly this while implementing "limit_value" in the other gem yesterday.
On Wednesday, May 6, 2015, Brian Underwood <[email protected] javascript:_e(%7B%7D,'cvml','[email protected]');> wrote:
Do you have a specific use case? I'm curious because I haven't run across a need for this when using ActiveRecord (doesn't mean it's not needed ;)
— Reply to this email directly or view it on GitHub https://github.com/neo4jrb/neo4j-core/issues/196#issuecomment-99389611.
Why did you need to use a different value if desc
was used? Can you point me to the gem code?
No, it's all work stuff. The gem creates cursor codes based on past queries, so subsequent queries change depending on how you sort initially.
On Friday, May 8, 2015, Brian Underwood [email protected] wrote:
Why did you need to use a different value if desc was used? Can you point me to the gem code?
— Reply to this email directly or view it on GitHub https://github.com/neo4jrb/neo4j-core/issues/196#issuecomment-100183135.
I used it in kaminari-neo4j gem to obtain a variable name from a return clause.
https://github.com/megorei/kaminari-neo4j/blob/d757ed35f0488bbf9a6ffb62550f50af690aee4a/lib/kaminari/neo4j/paginated.rb#L52
Not sure if it's necessary now.