Brian Cardarella
2011-Feb-08 20:54 UTC
Remove ActiveRecord::Relation#& alias for ''merge'' ? (or at least only reference and not use in AR)
Would the core team be open to the removal of the ''&'' alias for ActiveRecord::Relation#merge? 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? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Aaron Patterson
2011-Feb-10 18:21 UTC
Re: Remove ActiveRecord::Relation#& alias for ''merge'' ? (or at least only reference and not use in AR)
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/
Ernie Miller
2011-Feb-10 18:27 UTC
Re: Remove ActiveRecord::Relation#& alias for ''merge'' ? (or at least only reference and not use in AR)
On Feb 10, 2011, at 1:21 PM, Aaron Patterson wrote:> 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.> [...] > > At the very least, file a ticket for me so I don''t forget. Patches > would be nice too, but aren''t necessary. ;-) >Thanks, Aaron! I''ll get a patch for master ready shortly. -- Ernie Miller http://metautonomo.us -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Ernie Miller
2011-Feb-10 19:42 UTC
Re: Remove ActiveRecord::Relation#& alias for ''merge'' ? (or at least only reference and not use in AR)
On Feb 10, 1:27 pm, Ernie Miller <er...@metautonomo.us> wrote:> On Feb 10, 2011, at 1:21 PM, Aaron Patterson wrote: > > > 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. > > [...] > > > At the very least, file a ticket for me so I don''t forget. Patches > > would be nice too, but aren''t necessary. ;-) > > Thanks, Aaron! I''ll get a patch for master ready shortly. >Patches for 3-0-stable and master are both at https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/6407-deprecate-relation-in-3-0-stable-and-remove-in-master -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Brian Cardarella
2011-Feb-27 03:00 UTC
Re: Remove ActiveRecord::Relation#& alias for ''merge'' ? (or at least only reference and not use in AR)
Sweet! I totally missed out on the follow ups to this thread. Thanks! - Brian On Feb 10, 2:42 pm, Ernie Miller <er...@metautonomo.us> wrote:> On Feb 10, 1:27 pm, Ernie Miller <er...@metautonomo.us> wrote: > > > On Feb 10, 2011, at 1:21 PM, Aaron Patterson wrote: > > > > 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. > > > [...] > > > > At the very least, file a ticket for me so I don''t forget. Patches > > > would be nice too, but aren''t necessary. ;-) > > > Thanks, Aaron! I''ll get a patch for master ready shortly. > > Patches for 3-0-stable and master are both athttps://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/6...-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.