This project is archived and is in readonly mode.
ARel master generates invalid has and belongs to many SQL with Rails stable
Reported by Brian Cardarella | January 24th, 2011 @ 08:00 PM
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)
Comments and changes to this ticket
-
Brian Cardarella January 24th, 2011 @ 08:02 PM
FYI, this is the join SQL that is generated with ARel/master
https://gist.github.com/793845 -
Aaron Patterson January 24th, 2011 @ 09:30 PM
- 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.
-
Brian Cardarella January 24th, 2011 @ 09:32 PM
It does.
My desire it to have ARel master in the Rails 3.0.x branch.
-
Aaron Patterson January 25th, 2011 @ 04:40 AM
Brian, what feature from ARel master do you need for rails 3.0?
-
Brian Cardarella January 25th, 2011 @ 04:49 AM
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.
-
Brian Cardarella January 25th, 2011 @ 05:08 AM
So, that doesn't really explain why I want it in 3.0.
Well... how about the same reasons stated above only... sooner?
-
Aaron Patterson January 25th, 2011 @ 05:15 PM
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.
-
Brian Cardarella January 25th, 2011 @ 05:17 PM
That makes sense.
Would you be open to a patch that added Set operations to the 2-0-stable branch of Arel?
-
Brian Cardarella January 25th, 2011 @ 06:17 PM
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
-
Rohit Arondekar January 26th, 2011 @ 10:00 AM
- State changed from new to invalid
Closing as per request from Brian.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>