Skip to content
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

Can't do Arel operations with nodes #2

Open
rhymes opened this issue Dec 9, 2015 · 1 comment
Open

Can't do Arel operations with nodes #2

rhymes opened this issue Dec 9, 2015 · 1 comment

Comments

@rhymes
Copy link

rhymes commented Dec 9, 2015

Hello,

thank you for writing a library to simplify the syntactic sugar on using Arel nodes to address JSON fields.
There's a problem with your approach though: they don't support operations.

For example you can't do:

node = Arel::Nodes::JsonHashDoubleArrow.new(arel_node, Arel::Nodes.build_quoted("{json_path}"))
node.eq(value)

This will raise an exception because JsonHashDoubleArrow inherits from Arel::Nodes::Binary but does not include any of the operations, see for example how the InfixOperation is implemented: https://github.com/rails/arel/blob/master/lib/arel/nodes/infix_operation.rb

As you can see here https://github.com/rails/arel/blob/master/lib/arel/nodes/infix_operation.rb#L6 they include all the operations you can do on nodes, but your code just inherits from Binary: https://github.com/guyboertje/arel-pg-json/blob/master/lib/arel/nodes/pg_json.rb

@guyboertje
Copy link
Owner

I did not need to do operations on it so I did not see the need. What you see here is a MVP.

Sadly, (for this library) I do not use Rails and Postgres anymore and my days and nights are filled with LogStash code and plugin code, so I am not really able to give this library any attention.

Please provide a PR with tests and I will review and merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants