jit_preloader 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a3ebb3488bb221f516f32ebd2fbbedcee866b57d3ccc3c171f3843b9cc0af45
4
- data.tar.gz: 7bcaa0e57a6ee5541ca0fac7013f4188113f3425675df4ad29cab7cba3c8a540
3
+ metadata.gz: f6b03d3f3143dc42fbf4b980563021ed9462364d83bbb06d5c41065059c10478
4
+ data.tar.gz: 8d744ad7498e9ba3b60a01f094abd06db7a35fbbfdf594bba0cf74c9071622fe
5
5
  SHA512:
6
- metadata.gz: 7d696d0f3465be1aa319ae86c335e087b967847fefcd49a926e27c1cc24681be824ecc2a95a6365a129ae668f2abb341d570841f242cbb4b47295f974a3bf71e
7
- data.tar.gz: 5ac6f866cc9ee0fbab43e36d8bd2134e42782e6a6e9e4e635bd9b15e5951a02ed2d1d86b003afdbf5aeac736ffd3a23aadc7e9f75db1679cfd0768e132e2d5b4
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,3 +1,3 @@
1
1
  module JitPreloader
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
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.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: 2020-11-04 00:00:00.000000000 Z
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
- rubygems_version: 3.1.4
197
- signing_key:
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: