This project is archived and is in readonly mode.
Check for primary key in habtm when the association is defined
Reported by José Valim | September 1st, 2009 @ 12:22 PM
In this commit:
http://github.com/rails/rails/commit/9d51f6286680b832b0df5e3ce28857...
We started to check if the primary key in habtm was defined and raise an error if it does. However, the current implementation checks for it every time we insert a record for the first time, per association and then per request.
The patch attached changes it, so it's checked only when the association is defined. I was planning to move the logic to Reflection.check_validity!, but this method is invoked every time an association proxy is created. I tried to make check_validity! to be invoked just on load as well, but :through validity can only be ensured in runtime (when all records are supposed to be loaded).
Patch is for master and 2-3-stable.
Comments and changes to this ticket
-
Repository September 1st, 2009 @ 06:20 PM
- State changed from new to committed
(from [da636809daca9c338200811d3590e446f57c8e81]) Assert primary key does not exist in habtm when the association is defined, instead of doing that everytime a record is inserted.
[#3128 state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/da636809daca9c338200811d3590e4... -
Repository September 1st, 2009 @ 06:20 PM
(from [594a281d663dd8a7801651f4aea7e5b7f4f02548]) Assert primary key does not exist in habtm when the association is defined, instead of doing that everytime a record is inserted.
[#3128 state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/594a281d663dd8a7801651f4aea7e5... -
José Valim September 2nd, 2009 @ 10:09 PM
- State changed from committed to incomplete
Make tests fail on Postgres.
-
Repository September 2nd, 2009 @ 10:45 PM
- State changed from incomplete to open
(from [3b6a9a020e7e6f71ab6f9ffcf1ef59c57437ca69]) Revert "Assert primary key does not exist in habtm when the association is defined, instead of doing that everytime a record is inserted."
Test failures on PostgreSQL.
[#3128 state:open]
This reverts commit da636809daca9c338200811d3590e446f57c8e81.
http://github.com/rails/rails/commit/3b6a9a020e7e6f71ab6f9ffcf1ef59... -
Repository September 2nd, 2009 @ 10:46 PM
(from [2b82708b0efb3a3458e8177beab58f0c585788ae]) Revert "Assert primary key does not exist in habtm when the association is defined, instead of doing that everytime a record is inserted."
Test failures on PostgreSQL.
[#3128]
This reverts commit 594a281d663dd8a7801651f4aea7e5b7f4f02548.
http://github.com/rails/rails/commit/2b82708b0efb3a3458e8177beab58f... -
sds September 12th, 2009 @ 08:42 AM
Here is a patch to fix the issue in this code I reported in ticket #3190
- the issue being that has_primary_key? uses the ActiveRecord::Base's connection, which fails when using multiple databases (should use @owner.connection).
-
Repository September 12th, 2009 @ 10:57 AM
(from [d48d3d0f41f51e5da3f27105cdcee8a4c3852ea1]) Fix habtm associations when using multiple databases
[#3128]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/d48d3d0f41f51e5da3f27105cdcee8... -
Repository September 12th, 2009 @ 10:57 AM
(from [3180619c0d228812c119e9704ac5956cbcad8614]) Fix habtm associations when using multiple databases
[#3128]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/3180619c0d228812c119e9704ac595... -
Repository November 23rd, 2009 @ 06:42 PM
- State changed from open to resolved
(from [78790e47b8603917e2f2352f973a2de7769cb74b]) Revert "Revert "Assert primary key does not exist in habtm when the association is defined, instead of doing that everytime a record is inserted.""
This reverts commit 2b82708b0efb3a3458e8177beab58f0c585788ae.
[#3128 state:resolved]
Conflicts:
activerecord/lib/active_record/associations.rb activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
http://github.com/rails/rails/commit/78790e47b8603917e2f2352f973a2d...
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
- 3128 Check for primary key in habtm when the association is defined [#3128 state:resolved]
- 3128 Check for primary key in habtm when the association is defined [#3128 state:committed]
- 3128 Check for primary key in habtm when the association is defined [#3128 state:committed]
- 3128 Check for primary key in habtm when the association is defined [#3128 state:open]
- 3128 Check for primary key in habtm when the association is defined [#3128]
- 2086 Primary key on HABTM join table now raises an exception #3128 and #3190 are follow-ups on this feature.
- 3190 HABTM no longer works when using multiple databases sds, could you attach the patch to ticket #3128?
- 3128 Check for primary key in habtm when the association is defined [#3128]
- 3128 Check for primary key in habtm when the association is defined [#3128]