This project is archived and is in readonly mode.
HABTM no longer works when using multiple databases
Reported by sds | September 11th, 2009 @ 11:03 AM
The check has_primary_key? in has_and_belongs_to_many_association.rb fails when using multiple databases because it uses ActiveRecord::Base's connection and not the correct connection for the association.
This change changes it to use the @owner connection.
This first broke on this commit
http://github.com/rails/rails/commit/9c1bac0b7fcb627640db6824dca3e6...
- which was removed by commit
http://github.com/rails/rails/commit/594a281d663dd8a7801651f4aea7e5...
- but was again added by this commit
http://github.com/rails/rails/commit/2b82708b0efb3a3458e8177beab58f...
I enclose a patch to fix it.
Comments and changes to this ticket
-
José Valim September 11th, 2009 @ 09:04 PM
Actually, I think we should remove the code all together. The feature is great, but the implementation is very slow. My patch attemps to solve it, but fails in Postgres for a strange reason.
-
Jeremy Kemper September 11th, 2009 @ 10:10 PM
- State changed from new to duplicate
sds, could you attach the patch to ticket #3128?
-
erzapito October 16th, 2009 @ 11:46 AM
the delete_records method also fails:
line 90 is:
@c.delete(sql)and should be:
@owner.connection.delete(sql)
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
Tags
Referenced by
- 2086 Primary key on HABTM join table now raises an exception #3128 and #3190 are follow-ups on this feature.
- 3128 Check for primary key in habtm when the association is defined Here is a patch to fix the issue in this code I reported ...