On Tue, Feb 08, 2011 at 12:54:40PM -0800, Brian Cardarella wrote:
> Would the core team be open to the removal of the '&' alias for
> ActiveRecord::Relation#merge?

Yes, this seems fine to me.  We should add a deprecation warning in
3.0.x, then remove the method in master.

> The reason is that in Ruby the '&' operator refers to an intersection
> of two sets of data, not a merge. (within the context of the Array
> class)
> 
> Recently Arel added support for SQL Set Operators:
> 
> 2-0-stable: 
> https://github.com/rails/arel/commit/9e816c406399139d9ca76d2089df7f2d94d4fb8b
> master: 
> https://github.com/rails/arel/commit/74caeaad157e79853b9c6804f561d3c70eea2346
> and 
> https://github.com/rails/arel/commit/d532b7ee430c5d0c412ab9f1a5e0dd3ebc47f86b
> 
> So this allows for a higher level abstraction to use the Array class'
> convention:
> 
> '|' => Union
> '+' => UnionALL
> '&' => Intersect
> '-' => Except (Minus for Oracle)
> 
> to operate on two ActiveRecord::Relation instances.
> 
> This is sitting as a pending pull request on MetaWhere:
> https://github.com/ernie/meta_where/pull/12
> 
> Ernie Miller and I have been going back and forth. Ernie points out
> that ActiveRecord is using the alias '&' a few times in the code base
> instead of 'merge' and overriding this method in MetaWhere would cause
> some major issues.
> 
> Thoughts?

At the very least, file a ticket for me so I don't forget.  Patches
would be nice too, but aren't necessary.  ;-)

-- 
Aaron Patterson
http://tenderlovemaking.com/

Attachment: pgpfDRZNhClIM.pgp
Description: PGP signature

Reply via email to