This project is archived and is in readonly mode.
[PATCH] Fixed non-standard SQL generated by preloading has_and_belongs_to_many associations
Reported by Brent Miller | November 18th, 2008 @ 05:41 PM | in 2.x
This is a follow-up to ticket #394. After #394 was set to "resolved" there was discussion of another bug in the SQL that never got resolved.
The habtm :joins clause includes an extra "as" that generates non-standard SQL, causing it to break in Oracle. In INNER JOIN clauses, you can "INNER JOIN my_table t0" but you can't "INNER JOIN my_table as t0" which is the current behavior. MySQL and other dbs are tolerant of the extra "as," but Oracle throws a fit.
You can verify this with a SQL syntax checker: http://developer.mimer.com/valid...
Old output:
SELECT developers.*, t0.project_id as _parent_record_id
FROM developers
INNER JOIN developers_projects as t0 ON developers.id = t0.developer_id
WHERE (t0.project_id IN (1,2))
New output:
SELECT developers.*, t0.project_id as _parent_record_id
FROM developers
INNER JOIN developers_projects t0 ON developers.id = t0.developer_id
WHERE (t0.project_id IN (1,2))
No new tests are necessary, as no new behaviors are being added.
Comments and changes to this ticket
-
Repository December 1st, 2008 @ 07:22 PM
- State changed from new to committed
(from [0c4ba90aa1ea6a8d386c724a55a31e63a13c46ab]) Removed extra 'as' in :joins clause for habtm preloading
Signed-off-by: Michael Koziarski michael@koziarski.com
[#1405 state:committed] http://github.com/rails/rails/co...
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>
People watching this ticket
Attachments
Referenced by
- 394 [PATCH] Fixed non-standard SQL generated by preloading has_and_belongs_to_many associations Since this ticket seems to be closed, the "as" issue is b...
- 1405 [PATCH] Fixed non-standard SQL generated by preloading has_and_belongs_to_many associations [#1405 state:committed] http://github.com/rails/rails/co...