identity_cache 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/identity_cache/query_api.rb +1 -1
- data/lib/identity_cache/version.rb +1 -1
- data/test/prefetch_associations_test.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9803848d2879cfdaad2424842b64db3684e1ca4
|
4
|
+
data.tar.gz: 91cd873cffd35d19d66b01c8a10165344b30483d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d65519bb48cdae9d0111280e05a89cee2e99a497f31d0140f3e77ca55226865ef8c575ec9bd427e41ba9fd105e304c0a006d2fa4348ce6b06393c0ed607a8e23
|
7
|
+
data.tar.gz: 370c4a4d3406b95b9fe40b33406182286d9586dc07db2f2517a87bb08111fafa776dead8a5430555564aefdb385a9f5ce027c511e87c32924a8e8668af00a863
|
data/CHANGELOG.md
CHANGED
@@ -401,7 +401,7 @@ module IdentityCache
|
|
401
401
|
when details = cached_has_ones[association]
|
402
402
|
if details[:embed] == true
|
403
403
|
prefetch_embedded_association(records, association, details)
|
404
|
-
parent_records = records.map(&details[:cached_accessor_name].to_sym)
|
404
|
+
parent_records = records.map(&details[:cached_accessor_name].to_sym).compact
|
405
405
|
else
|
406
406
|
raise ArgumentError.new("Non-embedded has_one associations do not support prefetching yet.")
|
407
407
|
end
|
@@ -124,6 +124,21 @@ class PrefetchAssociationsTest < IdentityCache::TestCase
|
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
|
+
def test_prefetch_associations_through_nil_cache_has_one_association
|
128
|
+
Item.send(:cache_has_one, :associated, embed: true)
|
129
|
+
AssociatedRecord.send(:cache_has_many, :deeply_associated_records, embed: :ids)
|
130
|
+
bob_child = @bob.create_associated!(name: "bob child")
|
131
|
+
bob_child.deeply_associated_records.create!(name: "deep child")
|
132
|
+
AssociatedRecord.fetch_multi(bob_child.id)
|
133
|
+
Item.fetch_multi(@bob.id, @joe.id)
|
134
|
+
|
135
|
+
assert_memcache_operations(2) do
|
136
|
+
cached_bob, cached_joe = Item.fetch_multi(@bob.id, @joe.id, includes: {:associated => :deeply_associated_records})
|
137
|
+
assert_nil cached_joe.fetch_associated
|
138
|
+
assert_equal 'deep child', cached_bob.fetch_associated.fetch_deeply_associated_records.first.name
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
127
142
|
def test_fetch_with_includes_option
|
128
143
|
Item.send(:cache_belongs_to, :item)
|
129
144
|
john = Item.create!(title: 'john')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: identity_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Camilo Lopez
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2017-02-
|
17
|
+
date: 2017-02-09 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: ar_transaction_changes
|