New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
connection_pool issue for arel_tables #5399
Comments
Good description, thanks! I created a test app in Rails 3.1.4 and it works fine, so this seems to be a regression. |
…nnectionSpecification objects.
Nice. I can confirm that this resolves the problem. |
Thank you for confirmation :) |
Fix GH #5399. connection_pools's keys are ActiveRecord::Base::ConnectionSpecification objects.
…ord::Base::ConnectionSpecification objects.
Thanks @tenderlove, was almost sure this was an adapter bug at first. Took some digging. Please @kennyj or anyone, would love to see this make it's way to next 3-2-stable release. Hard to believe this was a regression. Guess I deal with multiple DBs to often too :) |
[3-2-stable] Fix GH #5399. connection_pools's keys are ActiveRecord::Base::ConnectionSpecification objects.
I'm closing this issue, because the above fix is merged. Thanks. |
Is this fixed for rails 3.1? |
@vishakhasawant it's unlikely, I see merges for master and 3-2. Moreover, 3.1 is only getting security fixes lately, I'd recommend migrating to 3-2 if possible. |
@carlosantoniodasilva I have rails 3.2.0 version now but it seems it works if I add below lines to my model @arel_table = Arel::Table.new(self.table_name, self)
@relation = ActiveRecord::Relation.new(self, @arel_table). Do I have to switch some minor version of rails 3.2? |
Apparently the merge commit exists on 3.2.3 forward: $ g tag --contains 596ecf753eb87ee4f11fc87682b321c64b09d733
v3.2.3
v3.2.3.rc1
v3.2.3.rc2
v3.2.4
v3.2.4.rc1
v3.2.5
v3.2.6
v3.2.7
v3.2.7.rc1
v3.2.8
v3.2.8.rc1
v3.2.8.rc2
v3.2.9
v3.2.9.rc1
v3.2.9.rc2
v3.2.9.rc3 Best would be for you to be on the latest stable version always. |
@carlosantoniodasilva Thanks a lot for your reply. |
No problem @vishakhasawant :) |
rails-sqlserver/activerecord-sqlserver-adapter#173
Summary: When using a model that has a base class that does an establish_connection to a database that is different from the default, the arel_table associated with that model is connected to the default database rather than the database to which it should be connected. This manifests itself in any manipulation of the arel table, for example by calling offset within the model.
This came up in an issue being discussed on the activerecord-sqlserver-adapter project (see link above).
To reproduce:
This points at the sqlite connection that is the default.
We suspect that the problem may be related to ActiveRecord's arel_engine method (in base.rb or core.rb depending on your version). This method is trying to find the connection_pools by name. However, at some point these pools became no longer keyed by name, but rather by ActiveRecord::Base::ConnectionSpecification objects. This results in the connection being kicked up to the superclass repeatedly, ultimately landing on ActiveRecord::Base.
The text was updated successfully, but these errors were encountered: