goldiloader 4.1.1 → 4.1.2
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: 14cd0ebc332f63f4f019029af0c75254207ad6b3957d3204b458200ffe89aa61
|
4
|
+
data.tar.gz: 151fe68d70ebc800bd471204106d49e7208678b6f0d5e1495a08302859f8574d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b387491503a50e6108c0fb3df8419eaea1032a302908afbaa0302582e37819250eecf569fb53c7eb29f4d204fe2d799b4fd0e5f71f9afc026b104370e5132b6
|
7
|
+
data.tar.gz: 62554443b9814f9487f63a39e2cd6c0da8bd85fc0985fc87f078e21b812f91d453676c72db9794d8d40fb5d04edd3e7220cad9aaf2c7bb94c374604b6b8de815
|
@@ -15,7 +15,7 @@ module Goldiloader
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def eager_load(models, association_name)
|
18
|
-
if Goldiloader::Compatibility.
|
18
|
+
if Goldiloader::Compatibility.pre_rails_7?
|
19
19
|
::ActiveRecord::Associations::Preloader.new.preload(models, [association_name])
|
20
20
|
else
|
21
21
|
::ActiveRecord::Associations::Preloader.new(records: models, associations: [association_name]).call
|
@@ -37,7 +37,13 @@ module Goldiloader
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def register_models(models)
|
40
|
-
Array.wrap(
|
40
|
+
# Don't use Array() or Array.wrap() because they will check respond_to?(:to_ary)
|
41
|
+
# which for ActiveStorage::Attachment will delegate to the blob association which
|
42
|
+
# triggers an infinite eager loading loop on the association
|
43
|
+
models = [models] unless models.is_a?(Array)
|
44
|
+
models.each do |model|
|
45
|
+
next if model.nil?
|
46
|
+
|
41
47
|
model.auto_include_context = self
|
42
48
|
self.models << model
|
43
49
|
end
|
@@ -3,11 +3,22 @@
|
|
3
3
|
module Goldiloader
|
4
4
|
module Compatibility
|
5
5
|
ACTIVE_RECORD_VERSION = ::Gem::Version.new(::ActiveRecord::VERSION::STRING).release
|
6
|
-
PRE_RAILS_6_2 = ACTIVE_RECORD_VERSION < ::Gem::Version.new('6.2.0')
|
7
6
|
RAILS_5_2_0 = ACTIVE_RECORD_VERSION == ::Gem::Version.new('5.2.0')
|
8
7
|
|
9
|
-
def self.
|
10
|
-
|
8
|
+
def self.pre_rails_7?
|
9
|
+
::ActiveRecord::VERSION::MAJOR < 7
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.rails_5_2?
|
13
|
+
::ActiveRecord::VERSION::MAJOR == 5 && ::ActiveRecord::VERSION::MINOR == 2
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.rails_6_1?
|
17
|
+
::ActiveRecord::VERSION::MAJOR == 6 && ::ActiveRecord::VERSION::MINOR == 1
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.rails_6_1_or_greater?
|
21
|
+
::ActiveRecord::VERSION::MAJOR > 6 || rails_6_1?
|
11
22
|
end
|
12
23
|
|
13
24
|
# See https://github.com/rails/rails/pull/32375
|
data/lib/goldiloader/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: goldiloader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Turkel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -50,6 +50,26 @@ dependencies:
|
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '7.1'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: activestorage
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '5.2'
|
60
|
+
- - "<"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '7.1'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '5.2'
|
70
|
+
- - "<"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '7.1'
|
53
73
|
- !ruby/object:Gem::Dependency
|
54
74
|
name: appraisal
|
55
75
|
requirement: !ruby/object:Gem::Requirement
|