n1_loader 1.6.6 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +45 -0
- data/lib/n1_loader/active_record/associations_preloader_v5.rb +2 -2
- data/lib/n1_loader/active_record/associations_preloader_v6.rb +2 -2
- data/lib/n1_loader/active_record/associations_preloader_v7.rb +2 -2
- data/lib/n1_loader/core/loader.rb +1 -1
- data/lib/n1_loader/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35755dbc6a0ae17e636a26aaa99d903714a2e61248f60cc7a6c23f0d1ff5cbdd
|
4
|
+
data.tar.gz: 34ebd3c7c2d873fb42fce414c74055251ef6169df1a06ec6255a857598c8fdf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4233a0b750ccfa3e001b512a379fb5a68758c45117fdaa0b5ec9cfd1c84d344c7e261ee61927794db2246aaa6c40b9576d5a19d1e547e65f6e08eab21de903d
|
7
|
+
data.tar.gz: ee26e611bf87f7daf78912f01996bd7330a0dbb0d74e18a38af79b7f4869b6c43365694ef5f8597a8f1574e5cb16ff1ca4bf73421019215b29f139e4917510e9
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,48 @@
|
|
1
|
+
## [1.7.1] - 2023/07/30
|
2
|
+
|
3
|
+
- Fix interface discrepancy for `N1LoaderReflection`. Thanks [Denis Talakevich](https://github.com/senid231) for suggesting it!
|
4
|
+
|
5
|
+
## [1.7.0] - 2023/07/30
|
6
|
+
|
7
|
+
Extend the flexibility of loading data comparison. Thanks [Nazar Matus](https://github.com/FunkyloverOne) for suggesting it!
|
8
|
+
|
9
|
+
**BREAKING CHANGES:**
|
10
|
+
|
11
|
+
Loose comparison of loaded data. Before loaded data was initialized with identity comparator in mind:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
@loaded = {}.compare_by_identity
|
15
|
+
```
|
16
|
+
|
17
|
+
Now it will be:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
@loaded = {}
|
21
|
+
```
|
22
|
+
|
23
|
+
This might bring unwanted results for cases when strict comparison was wanted.
|
24
|
+
|
25
|
+
On the other hand, it gives more flexibility for many other cases, especially with isolated loader.
|
26
|
+
For example, this will work now, when it wasn't working before.
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
# ActiveRecord object
|
30
|
+
object = Entity.first
|
31
|
+
|
32
|
+
# Initialize isolated loader
|
33
|
+
instance = loader.new([object])
|
34
|
+
|
35
|
+
# This was working before because the loaded object is identical to passed object by `#object_id`
|
36
|
+
instance.for(object)
|
37
|
+
|
38
|
+
# This wasn't working before because the loaded object is not identical to passed one by `#object_id`
|
39
|
+
#
|
40
|
+
# But it will be working now, because object == Entity.find(object.id)
|
41
|
+
instance.for(Entity.find(object.id))
|
42
|
+
```
|
43
|
+
|
44
|
+
If you need strict comparison support, please feel free to open the issue or the PR.
|
45
|
+
|
1
46
|
## [1.6.6] - 2023/07/30
|
2
47
|
|
3
48
|
- Fix naive check of required arguments. Thanks [Nazar Matus](https://github.com/FunkyloverOne) for the issue!
|
@@ -4,7 +4,7 @@ module N1Loader
|
|
4
4
|
module ActiveRecord
|
5
5
|
module Associations
|
6
6
|
module Preloader # :nodoc:
|
7
|
-
N1LoaderReflection = Struct.new(:
|
7
|
+
N1LoaderReflection = Struct.new(:name, :loader) do
|
8
8
|
def options
|
9
9
|
{}
|
10
10
|
end
|
@@ -12,7 +12,7 @@ module N1Loader
|
|
12
12
|
|
13
13
|
def preloaders_for_one(association, records, scope)
|
14
14
|
grouped_records(association, records).flat_map do |reflection, klasses|
|
15
|
-
next N1Loader::Preloader.new(records).preload(reflection.
|
15
|
+
next N1Loader::Preloader.new(records).preload(reflection.name) if reflection.is_a?(N1LoaderReflection)
|
16
16
|
|
17
17
|
klasses.map do |rhs_klass, rs|
|
18
18
|
loader = preloader_for(reflection, rs).new(rhs_klass, rs, reflection, scope)
|
@@ -4,7 +4,7 @@ module N1Loader
|
|
4
4
|
module ActiveRecord
|
5
5
|
module Associations
|
6
6
|
module Preloader # :nodoc:
|
7
|
-
N1LoaderReflection = Struct.new(:
|
7
|
+
N1LoaderReflection = Struct.new(:name, :loader) do
|
8
8
|
def options
|
9
9
|
{}
|
10
10
|
end
|
@@ -13,7 +13,7 @@ module N1Loader
|
|
13
13
|
def preloaders_for_reflection(reflection, records, scope)
|
14
14
|
return super unless reflection.is_a?(N1LoaderReflection)
|
15
15
|
|
16
|
-
N1Loader::Preloader.new(records).preload(reflection.
|
16
|
+
N1Loader::Preloader.new(records).preload(reflection.name)
|
17
17
|
end
|
18
18
|
|
19
19
|
def grouped_records(association, records, polymorphic_parent)
|
@@ -4,7 +4,7 @@ module N1Loader
|
|
4
4
|
module ActiveRecord
|
5
5
|
module Associations
|
6
6
|
module Preloader # :nodoc:
|
7
|
-
N1LoaderReflection = Struct.new(:
|
7
|
+
N1LoaderReflection = Struct.new(:name, :loader) do
|
8
8
|
def options
|
9
9
|
{}
|
10
10
|
end
|
@@ -13,7 +13,7 @@ module N1Loader
|
|
13
13
|
def preloaders_for_reflection(reflection, records)
|
14
14
|
return super unless reflection.is_a?(N1LoaderReflection)
|
15
15
|
|
16
|
-
N1Loader::Preloader.new(records).preload(reflection.
|
16
|
+
N1Loader::Preloader.new(records).preload(reflection.name)
|
17
17
|
end
|
18
18
|
|
19
19
|
def grouped_records # rubocop:disable Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/AbcSize
|
data/lib/n1_loader/version.rb
CHANGED