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
Fix #6951. Use query cache/uncache, when using not only database.yml but also DATABASE_URL. #8074
Conversation
@kennyj could you add a CHANGELOG entry? |
@@ -14,7 +14,7 @@ def cache(&block) | |||
|
|||
# Disable the query cache within the block if Active Record is configured. | |||
def uncached(&block) | |||
if ActiveRecord::Base.configurations.blank? | |||
unless ActiveRecord::Base.connected? | |||
yield | |||
else | |||
connection.uncached(&block) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should invert the unless..else
block here, wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some people really really really hate unless/else, but it doesn't bother me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hehe.. I don't hate, but I try to avoid :)
….yml but also DATABASE_URL.
Thanks guys. I don't like |
Fix #6951. Use query cache/uncache, when using not only database.yml but also DATABASE_URL.
…g not only database.yml but also DATABASE_URL.
Backport #8074 to 3-2-stable. Use query cache/uncache, when using not only database.yml but also DATABASE_URL.
This PR closes #6951.
If we use
DATABASE_URL
,ActiveRecord::Base.configurations
is not populated. Thus we can't use query cache with DATABASE_URL.See https://github.com/rails/rails/blob/master/activerecord/lib/active_record/query_cache.rb#L7