ar_lazy_preload 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/lib/ar_lazy_preload/version.rb +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d54ffe605f60682678626dc9fb88be7490cccc9d9d8e9d012e2118c97806531
|
4
|
+
data.tar.gz: d88d6afa1cd40385645771b6b8117df04e57af4753ab062c92a0dbe231836dc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0865957982e3b35ab825b0a800c391a27989026865ca8efcd7c4b2f664e4054b2dcd92926ee3ed75ca81f2e4bc2d38fb61aa75f635f72256554fffd944eef93
|
7
|
+
data.tar.gz: b06ed1f0e44254b1d2e4660f0aa63e257c1dba54383e14d480c7852d92f3912a356e67f236f3e1107621db1a3b80a8abaf8ebbf31413f50f870ceb8c586aadfe
|
data/README.md
CHANGED
@@ -60,6 +60,19 @@ posts = User.preload_associations_lazily.flat_map(&:posts)
|
|
60
60
|
# => SELECT * FROM posts WHERE user_id in (...)
|
61
61
|
```
|
62
62
|
|
63
|
+
## Gotchas
|
64
|
+
|
65
|
+
1. Lazy preloading [does not work](https://github.com/DmitryTsepelev/ar_lazy_preload/pull/40/files) when `.includes` is called earlier:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
Post.includes(:user).preload_associations_lazily.each do |p|
|
69
|
+
p.user.comments.load
|
70
|
+
end
|
71
|
+
```
|
72
|
+
|
73
|
+
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`).
|
74
|
+
|
75
|
+
|
63
76
|
## Installation
|
64
77
|
|
65
78
|
Add this line to your application's Gemfile, and you're all set:
|
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: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DmitryTsepelev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -81,7 +81,21 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov-lcov
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - ">="
|
@@ -196,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
210
|
- !ruby/object:Gem::Version
|
197
211
|
version: '0'
|
198
212
|
requirements: []
|
199
|
-
rubygems_version: 3.
|
213
|
+
rubygems_version: 3.0.3
|
200
214
|
signing_key:
|
201
215
|
specification_version: 4
|
202
216
|
summary: lazy_preload implementation for ActiveRecord models
|