Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ARel master generates invalid has and belongs to many SQL with Rails stable

#6330

Test: https://gist.github.com/793838

You need the master branch of ARel installed for this test to fail

Conversation: https://github.com/rails/arel/commit/9653da3c7963834eb9ed93bf248371...

It would be nice if we could get master ARel in the next stable release of Rails 3.0.x (presumed 3.0.4)

Reported by Brian Cardarella · January 24th, 2011 @ 08:00 PM

State: invalid
Milestone: none
Assigned to: Aaron Patterson Aaron Patterson
Importance: Low

Activity

  1. Brian Cardarella
    Brian Cardarella

    FYI, this is the join SQL that is generated with ARel/master
    https://gist.github.com/793845

    January 24th, 2011 @ 08:02 PM

  2. Aaron Patterson
    Aaron Patterson
    • Importance changed from to Low

    Brian, if you use rails master, does this problem go away?

    ARel master really isn't compatible with Rails 3-0-stable.

    January 24th, 2011 @ 09:30 PM

  3. Brian Cardarella
    Brian Cardarella

    It does.

    My desire it to have ARel master in the Rails 3.0.x branch.

    January 24th, 2011 @ 09:32 PM

  4. Aaron Patterson
    Aaron Patterson

    Brian, what feature from ARel master do you need for rails 3.0?

    January 25th, 2011 @ 04:40 AM

  5. Brian Cardarella
    Brian Cardarella

    I would like the new Set operators I added. See the conversation I had with myself here:

    https://github.com/ernie/meta_where/pull/11

    In summary, it would be awesome (with MetaWhere) to do stuff like:

    Developer.where(:created_at.gt => 1.day.from_now) - Developer.where(:created_at.lt => 20.days.from_now)
    

    (the syntactic sugar on the symbols is possible with the MetaWhere gem)

    It wouldn't be that much work for me to overload the '-' operator to have this result in an EXCEPT set operation. The same could apply for the other operators.

    While I'm on my soapbox I'm going to advocate that the '&' operator shouldn't have been used as an alias for ActiveRecord::Relations#merge. As I mention in the link above It would be nice to follow the convention for Set operators that already exit for the Array class. In this case the '+' operator would be more appropriate. And '&' would be used for INTERSECT.

    January 25th, 2011 @ 04:49 AM

  6. Brian Cardarella
    Brian Cardarella

    So, that doesn't really explain why I want it in 3.0.

    Well... how about the same reasons stated above only... sooner?

    January 25th, 2011 @ 05:08 AM

  7. Aaron Patterson
    Aaron Patterson

    So this isn't fixing a bug, but adding a feature. I don't like the idea of adding a new feature to a bugfix release of ARel, so it could not go in ARel 2.0.x.

    I suppose it's possible to make the next release of Rails depend on ARel 2.1.x, but that may require much effort. I don't think it's a good idea to make that many changes to a bugfix release of Rails (especially considering this is not a bug).

    It's tough waiting for new features, but unless stuff is actually broken on 3-0-stable, I don't think we should fix it.

    January 25th, 2011 @ 05:15 PM

  8. Brian Cardarella
    Brian Cardarella

    That makes sense.

    Would you be open to a patch that added Set operations to the 2-0-stable branch of Arel?

    January 25th, 2011 @ 05:17 PM

  9. Brian Cardarella
    Brian Cardarella

    So this should probably be closed and I've opened a tick on the Arel Lighthouse: http://arel.lighthouseapp.com/projects/36051-arel/tickets/11-patch-...

    I've also submitted a pull request for the rail/arel@2-0-stable branch to backport the set operators: https://github.com/rails/arel/pull/26

    January 25th, 2011 @ 06:17 PM

  10. Rohit Arondekar
    Rohit Arondekar
    • State changed from new to invalid

    Closing as per request from Brian.

    January 26th, 2011 @ 10:00 AM