jit_preloader 1.0.0 → 1.0.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6b03d3f3143dc42fbf4b980563021ed9462364d83bbb06d5c41065059c10478
|
4
|
+
data.tar.gz: 8d744ad7498e9ba3b60a01f094abd06db7a35fbbfdf594bba0cf74c9071622fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33a93b1c222276bce861ca4f441b5f4f9773f6337e39762422defe3fd3a7dedd360626512bb4869cf9b6b1c216035b93caca857093561a7c0378164e8e404085
|
7
|
+
data.tar.gz: c5c34143399f102bf1b20e8f6614cb077debad960b435d42733fbcfd8657a4be7fbec34a8e6883f614e68c1f5a19673d86ce1526f29c124463397fe8fc38aaa6
|
@@ -18,6 +18,8 @@ module JitPreloader
|
|
18
18
|
# end
|
19
19
|
|
20
20
|
def run(preloader)
|
21
|
+
return unless (reflection.scope.nil? || reflection.scope.arity == 0) && klass.ancestors.include?(ActiveRecord::Base)
|
22
|
+
|
21
23
|
super.tap do
|
22
24
|
if preloaded_records.any? && preloaded_records.none?(&:jit_preloader)
|
23
25
|
JitPreloader::Preloader.attach(preloaded_records) if owners.any?(&:jit_preloader) || JitPreloader.globally_enabled?
|
@@ -16,6 +16,8 @@ module JitPreloader
|
|
16
16
|
# end
|
17
17
|
|
18
18
|
def run
|
19
|
+
return unless (reflection.scope.nil? || reflection.scope.arity == 0) && klass.ancestors.include?(ActiveRecord::Base)
|
20
|
+
|
19
21
|
super.tap do
|
20
22
|
if preloaded_records.any? && preloaded_records.none?(&:jit_preloader)
|
21
23
|
JitPreloader::Preloader.attach(preloaded_records) if owners.any?(&:jit_preloader) || JitPreloader.globally_enabled?
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe JitPreloader::Preloader do
|
4
4
|
let!(:contact1) do
|
@@ -154,6 +154,16 @@ RSpec.describe JitPreloader::Preloader do
|
|
154
154
|
expect(c.contacts_count).to eql contact_owner_counts[i]
|
155
155
|
end
|
156
156
|
end
|
157
|
+
|
158
|
+
context "when a record has a polymorphic association type that's not an ActiveRecord" do
|
159
|
+
before do
|
160
|
+
contact1.update!(contact_owner_type: "NilClass", contact_owner_id: nil)
|
161
|
+
end
|
162
|
+
|
163
|
+
it "doesn't die while trying to load the association" do
|
164
|
+
expect(Contact.jit_preload.map(&:contact_owner)).to eq [nil, ContactOwner.first, Address.first]
|
165
|
+
end
|
166
|
+
end
|
157
167
|
end
|
158
168
|
end
|
159
169
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jit_preloader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle d'Oliveira
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -178,7 +178,7 @@ homepage: ''
|
|
178
178
|
licenses:
|
179
179
|
- MIT
|
180
180
|
metadata: {}
|
181
|
-
post_install_message:
|
181
|
+
post_install_message:
|
182
182
|
rdoc_options: []
|
183
183
|
require_paths:
|
184
184
|
- lib
|
@@ -193,8 +193,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
195
|
requirements: []
|
196
|
-
|
197
|
-
|
196
|
+
rubyforge_project:
|
197
|
+
rubygems_version: 2.7.6.2
|
198
|
+
signing_key:
|
198
199
|
specification_version: 4
|
199
200
|
summary: Tool to understand N+1 queries and to remove them
|
200
201
|
test_files:
|