mongoid_includes 3.0.0 → 3.0.2

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: '0813ebc58b1a52c13becbb4e8f99302aa4d2c2b1710cdb46bc682c1e9a8d8971'
4
- data.tar.gz: 1e63435cc73ad4a990881ff9b30432c00d3ff104cde4f17941a9acd553d82923
3
+ metadata.gz: a8d1edc191e71925a3462bf7016a3df71eca0d73c3257e805b1484b58ea5ecd9
4
+ data.tar.gz: 89b4566f274c31a0df1d61b34cc5f3c04dc8bc51718a6528987df2f3d5eb122c
5
5
  SHA512:
6
- metadata.gz: 037a555d455d291c2ac997864ee85134b8c6b6c7725149727e9dd054420f8c84b22d4a627375fa42f5c658530bfa521ad9b32b0eca8dcc4173abdbd811a62496
7
- data.tar.gz: e5b4824f1e880f4d5c3765748bc94358bf2bc0dd748c449db979689e17020b39992a58c5d496059f1030fa043a89af9202d31d5f70419b5bc27de3ca21202934
6
+ metadata.gz: f2adc7ec100121a377091f850489cd60e0de8a6f5a0c55f506482fc0241c2a679297bd6c20dd017ce1b223c186d3067008ef2d4673bc827ba4e82e9f17e867fc
7
+ data.tar.gz: c8c5b23eef7064c2f7e9f8af75806c3507e385684202140653d21dc6bb1f8f57ee628bf9b4f013b3d647bc5558eaffa14931d1edd73efd249aacded0ed518ef1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## Mongoid::Includes 3.0.2 (2022-11-03) ##
2
+
3
+ * [perf: avoid queries when foreign keys are empty](https://github.com/ElMassimo/mongoid_includes/commit/9f4c0c8bf1560a319c663fae77015c638caec56b)
4
+
5
+ ## Mongoid::Includes 3.0.1 (2022-11-03) ##
6
+
7
+ * Allow installing this library with Mongoid `8.0`.
8
+
1
9
  ## Mongoid::Includes 3.0.0 (2020-10-29) ##
2
10
 
3
11
  * Add support for Mongoid `7.1`.
data/README.md CHANGED
@@ -5,7 +5,7 @@ Mongoid::Includes
5
5
  [![Test Coverage](https://codeclimate.com/github/ElMassimo/mongoid_includes/badges/coverage.svg)](https://codeclimate.com/github/ElMassimo/mongoid_includes)
6
6
  [![Code Climate](https://codeclimate.com/github/ElMassimo/mongoid_includes.svg)](https://codeclimate.com/github/ElMassimo/mongoid_includes)
7
7
  [![Inline docs](http://inch-ci.org/github/ElMassimo/mongoid_includes.svg)](http://inch-ci.org/github/ElMassimo/mongoid_includes)
8
- [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ElMassimo/mongoid_includes/blob/master/LICENSE.txt)
8
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ElMassimo/mongoid_includes/blob/main/LICENSE.txt)
9
9
 
10
10
  `Mongoid::Includes` improves eager loading in Mongoid, supporting polymorphic associations, and nested eager loading.
11
11
 
@@ -9,7 +9,11 @@ module Mongoid
9
9
  # Internal: Performs eager load and iterates over the preloaded documents
10
10
  # for the current relation.
11
11
  def each_loaded_document
12
- @association.load_documents_for(key, keys_from_docs).each do |doc|
12
+ foreign_key_values = keys_from_docs
13
+
14
+ return @association.klass.none if foreign_key_values.empty?
15
+
16
+ @association.load_documents_for(key, foreign_key_values).each do |doc|
13
17
  yield doc
14
18
  end
15
19
  end
@@ -5,6 +5,6 @@ module Mongoid
5
5
  module Includes
6
6
 
7
7
  # Public: This library will attempt to follow semantic versioning (whatever that's supposed to be).
8
- VERSION = '3.0.0'
8
+ VERSION = '3.0.2'
9
9
  end
10
10
  end