Skip to content
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

Merged
merged 1 commit into from Oct 31, 2012

Conversation

kennyj
Copy link
Contributor

@kennyj kennyj commented Oct 30, 2012

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

@rafaelfranca
Copy link
Member

@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)

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

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.

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 :)

@kennyj
Copy link
Contributor Author

kennyj commented Oct 31, 2012

Thanks guys. I don't like unless .. else too :)
I update and added a CHANGELOG entry.

rafaelfranca added a commit that referenced this pull request Oct 31, 2012
Fix #6951. Use query cache/uncache, when using not only database.yml but also DATABASE_URL.
@rafaelfranca rafaelfranca merged commit 85039d4 into rails:master Oct 31, 2012
kennyj added a commit to kennyj/rails that referenced this pull request Nov 13, 2012
…g not only database.yml but also DATABASE_URL.
rafaelfranca added a commit that referenced this pull request Nov 13, 2012
Backport #8074 to 3-2-stable. Use query cache/uncache, when using not only database.yml but also DATABASE_URL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cache and uncached do not work when using DATABASE_URL (such as on Heroku)
4 participants