-
Notifications
You must be signed in to change notification settings - Fork 464
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 caching using where and postgres #47
Comments
I've updated to the following without any change in behaviour.
I also add that it doesn't seem to be a problem if you're calling 'where' through a scope. |
If I issue the same commands without the use of a block, I get the results I expect. eg. Apartment::Database.switch("company_3")
User.where(:id => 100)
Apartment::Database.switch("company_4")
User.where(:id => 100) I'm so confused it hurts. Why would running these command by iterating over a list have different behaviour than executing the commands sequentially ? |
weeeird... I've definitely never seen that. We have quite a bit of code like that to loop through all tenants and do stuff with them, never had a problem. I'll see if I can replicate it sometime this week and get back to you. |
ah ok, I've been able to reproduce your problem, but it's just a problem with using the console and the way ActiveRecord::Relation's work. When you say The problem is, it loops once, builds a relation, loops again, builds a relation, then when it returns those two relations (and hence actually queries the db), they're within the scope of the 2nd If you were do do something like:
Then it would work properly. That's why your Just remember that |
Thanks for the explanation. That makes perfect sense. |
Hi I'm having an issue when using 'where' in a query. It appears to be returning the same results for each subsequent query on different database connections. For example:
However if I write the query using find_by_id, I get the results I expect having different names:
I have also tried calling Apartment.connection.clear_query_cache after each switch which doesn't affect the outcome. I've tried this with:
Is anyone able to reproduce this issue ? I'll try updating these gems and report back.
The text was updated successfully, but these errors were encountered: