--- orig 2007-07-02 11:45:27.000000000 -0400 +++ cached_model.rb 2007-07-02 11:43:59.000000000 -0400 @@ -146,7 +146,7 @@ # Find by primary key from the cache. def self.find_by_sql(*args) - return super unless args.first =~ /^SELECT \* FROM #{table_name} WHERE \(#{table_name}\.#{primary_key} = '?(\d+)'?\) +LIMIT 1/ + return super unless args.first =~ /^SELECT \* FROM #{table_name} WHERE \(#{table_name}\.\"?#{primary_key}\"? = '?(\d+)'?\)\s*[LIMIT 1]?$/i id = $1.to_i # Try to find the record in the local cache.