Bugs: Browse | Submit New | Admin

[#8038] Rails 1.2 Changes Break CachedModel (Fix found)

Date:
2007-01-21 08:11
Priority:
3
Submitted By:
Geoffrey Grosenbach (topfunky)
Assigned To:
Eric Hodel (drbrain)
Category:
cached_model
State:
Closed
Summary:
Rails 1.2 Changes Break CachedModel (Fix found)

Detailed description
CachedModel looks for a specific SQL query when deciding whether or not to cache a record. For single row finds, ActiveRecord
no longer uses "LIMIT 1", which is part of the SQL that CachedModel looks for. Thus, nothing is ever cached.

An initial fix is to remove "limit 1" from cached_model.rb line 149 (I think this would be backwards compatible
with older versions of Rails). A more robust fix would be to look for the ActiveRecord version (1.15.1) and specify
the corresponding query to match.

  def self.find_by_sql(*args)
    return super unless args.first =~ /^SELECT \* FROM #{table_name} WHERE \(#{table_name}\.#{primary_key} = '?(\d+)'?\)
+LIMIT 1/

Add A Comment: Notepad

Please login


Followup

Message
Date: 2007-03-07 03:51
Sender: Eric Hodel

I've already got an unreleased fix for this.

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

Field Old Value Date By
status_idOpen2007-03-07 03:51drbrain
resolution_idNone2007-03-07 03:51drbrain
close_date2007-03-07 03:512007-03-07 03:51drbrain