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

equality for Arel::Nodes #130

Closed
rapimo opened this issue Aug 2, 2012 · 1 comment
Closed

equality for Arel::Nodes #130

rapimo opened this issue Aug 2, 2012 · 1 comment

Comments

@rapimo
Copy link

rapimo commented Aug 2, 2012

when chaining custom selects in rails like

Model.select(table[:name].as('foo')).select(table[:name].as('foo'))

It produces duplicate select_values. Thats because the select_values array can't be made uniq in

ActiveRecord::QueryMethods#build_arel

Unlike

table[:name] == table[:name]
=> true

table[:name].as('foo') == table[:name].as('foo')
=> false

Wouldn't it make sense to implement equality for Arel::Nodes ?
Or to be more specific to have a proper implementation of the hash function for Arel::Nodes ?

@ernie
Copy link
Collaborator

ernie commented Aug 6, 2012

I'm 👍 on this, as well as equality for Arel::Attributes::Attribute etc. Ran into this on activerecord-hackery/squeel#153 recently. Given how much ActiveRecord relies on the concept of being able to uniq a collection for *_values, we should do what we can to help it along.

Happy to put in the work on this, unless another committer has opposition.

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

No branches or pull requests

2 participants