This project is archived and is in readonly mode.
ARel master generates invalid has and belongs to many SQL with Rails stable
-
Brian Cardarella
FYI, this is the join SQL that is generated with ARel/master
https://gist.github.com/793845 -
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.
-
Brian Cardarella
It does.
My desire it to have ARel master in the Rails 3.0.x branch.
-
Aaron Patterson
Brian, what feature from ARel master do you need for rails 3.0?
-
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.
-
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?
-
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.
-
Brian Cardarella
That makes sense.
Would you be open to a patch that added Set operations to the 2-0-stable branch of Arel?
-
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