ar_lazy_preload 2.0.0 → 2.1.0

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: 3f8b5858ee6bbfd4ba3db6c61f5577ef7651c06b63bb4c38ddc5dad7a61dba2d
4
- data.tar.gz: 1087cc1b4e487d6a6a404e3def90ee9dc3baf9b1c143b5a58176dbd27d206f40
3
+ metadata.gz: 82d5aeed661b9ab42f1d15f78cb8db84cc8b426ddfe26ae1442f297800ec0707
4
+ data.tar.gz: 1c89c0b2f8025143186551e06629c40a37bf8c207b7605c71481b02c158f89f5
5
5
  SHA512:
6
- metadata.gz: cd0d2df79afe940662c1cab747c0fa1e8d2dab46eaba585663a2441c0f1058bd56d355e16d1feba4a46af52fe81167133c0e1e42dc3e31212b702310e57d2f92
7
- data.tar.gz: 2398c417a95f0c1472b677647e74f5bbdd02c5c426f7d41b583d33557122642dbd0925feeb7ca62bbb36ad5ba5c934280e7e10d3898a3b4e9f8c4ac5c8e02c32
6
+ metadata.gz: acbedff3a73e2b26ee0a905c9b5059e9e27297abccd2a16c0a68c3bd67001a4d45721b83aaad21738b36d6c7bce8d41ea6756bd0f1bd54973f339ab2cc26ea68
7
+ data.tar.gz: 5285e4116f8ba49bc7aa2cbfc1962bfff112785ebd7dbed823ebadf606e9eef1f0772f7f30312344a00cbe8c76af37fc0378d422933073d8758bebe5ae6bcd85
data/README.md CHANGED
@@ -74,6 +74,7 @@ posts = User.preload_associations_lazily.flat_map(&:posts)
74
74
 
75
75
  2. When `#size` is called on association (e.g., `User.lazy_preload(:posts).map { |u| u.posts.size }`), lazy preloading won't happen, because `#size` method performs `SELECT COUNT()` database request instead of loading the association when association haven't been loaded yet ([here](https://github.com/DmitryTsepelev/ar_lazy_preload/pull/42) is the issue, and [here](https://blazarblogs.wordpress.com/2019/07/27/activerecord-size-vs-count-vs-length/) is the explanation article about `size`, `length` and `count`).
76
76
 
77
+ 3. Lazy preloading for **ActiveStorage** variants is not working automatically because of the way how it is implemented ([here](https://github.com/DmitryTsepelev/ar_lazy_preload/pull/70) is the issue). You can preload them manually by calling `#with_all_variant_records`/`#with_attached_#{attachment_name}` on association. Example: `User.with_attached_avatar.first(10).map { |u| u.avatar.variant(:small).processed.url }`
77
78
 
78
79
  ## Installation
79
80
 
@@ -92,7 +92,7 @@ module ArLazyPreload
92
92
 
93
93
  def preloadable_reflection?(klass, reflection)
94
94
  scope = reflection.scope
95
- preloadable_scope = scope&.arity&.zero?
95
+ preloadable_scope = scope&.arity&.zero? || ::ActiveRecord::VERSION::MAJOR >= 7
96
96
  through_reflection =
97
97
  reflection.options[:through] && klass.reflect_on_association(reflection.options[:through])
98
98
  preloadable_through_reflection =
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ArLazyPreload
4
- VERSION = "2.0.0"
4
+ VERSION = "2.1.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar_lazy_preload
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DmitryTsepelev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-10 00:00:00.000000000 Z
11
+ date: 2024-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '6.0'
19
+ version: '6.1'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '6.0'
26
+ version: '6.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.81.0
61
+ version: 1.57.2
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 0.81.0
68
+ version: 1.57.2
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: db-query-matchers
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -212,7 +212,7 @@ homepage: https://github.com/DmitryTsepelev/ar_lazy_preload
212
212
  licenses:
213
213
  - MIT
214
214
  metadata: {}
215
- post_install_message:
215
+ post_install_message:
216
216
  rdoc_options: []
217
217
  require_paths:
218
218
  - lib
@@ -220,15 +220,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
220
220
  requirements:
221
221
  - - ">="
222
222
  - !ruby/object:Gem::Version
223
- version: '2.7'
223
+ version: '3.0'
224
224
  required_rubygems_version: !ruby/object:Gem::Requirement
225
225
  requirements:
226
226
  - - ">="
227
227
  - !ruby/object:Gem::Version
228
228
  version: '0'
229
229
  requirements: []
230
- rubygems_version: 3.1.6
231
- signing_key:
230
+ rubygems_version: 3.4.10
231
+ signing_key:
232
232
  specification_version: 4
233
233
  summary: lazy_preload implementation for ActiveRecord models
234
234
  test_files: []