This project is archived and is in readonly mode.
AssociationCollection starts transactions in the incorrect database
Reported by Hongli Lai | September 20th, 2008 @ 09:15 PM | in 2.x
Some AssociationProxy methods, e.g. #clear, start transactions. However, they start the transaction in the wrong place. For example, suppose Author has_many :books. One would expect "author.books.clear" to start a transaction by calling Book.transaction, but the current implementation calls Author.transaction. Only has_and_belongs_to_many seems to get it right.
This patch fixes this bug, and also includes a unit test. All code in AssociationProxy subclasses now start transactions by calling AssociationProxy#transaction, which in turn calls .transaction on the association class. The reason why I added this method instead of calling @reflection.klass.transaction (as has_and_belongs_to_many does) is because I need the AssocationProxy#transaction hook for a database sharding plugin that I'm developing: the transaction needs to be activated in the correct shard, and this requires some additional housekeeping code.
The patch applies on 2-1-stable and on master.
Comments and changes to this ticket
-
Hongli Lai September 20th, 2008 @ 09:56 PM
- Title changed from AssociationProxy starts transactions in the incorrect database to AssociationCollection starts transactions in the incorrect database
Here's an updated patch. AssociationProxy#transaction has been moved to AssociationCollection because it makes no sense for non-collection associations. More tests have been added.
The following patch is for edge.
-
Repository September 23rd, 2008 @ 07:32 PM
- State changed from new to committed
(from [70b8ea4fa6f432919340345ae0d5af6aa8f87ec8]) Make AssociationCollection start transactions in the correct database.
AssociationCollection now starts transactions by calling AssociationCollection#transaction instead of @owner.transaction or @reflection.klass.transaction.
Signed-off-by: Michael Koziarski michael@koziarski.com
[#1081 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
Tags
Referenced by
- 1081 AssociationCollection starts transactions in the incorrect database [#1081 state:committed] http://github.com/rails/rails/co...
- 1240 This repo is too large to generate a tarball. Please file a bug report. also submitted to http://logicalawesome.lighthouse...