cached_model 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ $VERBOSE = nil
8
8
 
9
9
  spec = Gem::Specification.new do |s|
10
10
  s.name = 'cached_model'
11
- s.version = '1.2.0'
11
+ s.version = '1.2.1'
12
12
  s.summary = 'An ActiveRecord::Base model that caches records'
13
13
  s.authors = 'Robert Cottrell, Eric Hodel'
14
14
  s.email = 'bob@robotcoop.com'
@@ -168,7 +168,7 @@ class CachedModel < ActiveRecord::Base
168
168
 
169
169
  # Fetch the record from the DB
170
170
  records = super
171
- records.first.cache_store # only one
171
+ records.first.cache_store unless records.empty? # only one
172
172
  return records
173
173
  end
174
174
 
@@ -55,6 +55,7 @@ class ActiveRecord::Base
55
55
  end
56
56
 
57
57
  def self.find_by_sql(query)
58
+ return [] if query =~ /concrete\.id = -1/
58
59
  return [new]
59
60
  end
60
61
 
@@ -325,6 +326,14 @@ class TestCachedModel < Test::Unit::TestCase
325
326
  assert_equal record, Cache.cache[record.cache_key_memcache]
326
327
  end
327
328
 
329
+ def test_class_find_by_sql_no_record
330
+ q = "SELECT * FROM concrete WHERE (concrete.id = -1) LIMIT 1"
331
+
332
+ records = Concrete.find_by_sql q
333
+
334
+ assert_equal [], records
335
+ end
336
+
328
337
  def test_class_ttl
329
338
  assert_equal 900, CachedModel.ttl
330
339
  CachedModel.ttl = 800
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.99
3
3
  specification_version: 1
4
4
  name: cached_model
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.2.0
7
- date: 2006-08-10 00:00:00 -07:00
6
+ version: 1.2.1
7
+ date: 2006-08-18 00:00:00 -07:00
8
8
  summary: An ActiveRecord::Base model that caches records
9
9
  require_paths:
10
10
  - lib