equality for Arel::Nodes #130

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

Comments

Projects
None yet
2 participants

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 ?

Collaborator

ernie commented Aug 6, 2012

I'm 👍 on this, as well as equality for Arel::Attributes::Attribute etc. Ran into this on ernie/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.

@ernie ernie closed this in 6e638bb Aug 19, 2012

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