Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

Fix for migrations when query_cache is turned on.

#967

When I use this in my initializers on Rails 2.1.0 with sqlite3 on MacOSX: ActiveRecord::Base.connection.query_cache_enabled = true I can't run migrations at all.

Here's the output: MacBook:migration_cache_problem art$ rake db:migrate --trace (in /Users/art/development/projects/rails/mine/testbed/migration_cache_problem) Invoke db:migrate (first_time) Invoke environment (first_time) Execute environment Execute db:migrate rake aborted! You have a nil object when you didn't expect it! The error occurred while evaluating nil.has_key? /Users/art/development/projects/rails/mine/testbed/migration_cache_problem/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:91:in cache_sql' /Users/art/development/projects/rails/_mine/testbed/migration_cache_problem/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:74:inselect_all' /Users/art/development/projects/rails/_mine/testbed/migration_cache_problem/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:13:in select_one'

Attached a fix, that ensures, that query_cache is not nil.

Reported by Rene Androsch · September 3rd, 2008 @ 11:35 PM

State: invalid
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Pratik
    Pratik
    • State changed from new to invalid

    ActiveRecord::Base.connection.query_cache_enabled is an attr_reader and you shouldn't need to turn it on as it's always on.

    If you still face the issue, please upload a failing test case.

    Thanks.

    December 20th, 2008 @ 05:01 PM