Skip to content

Commit 9011459

Browse files
committed
Fix bug with nested includes when the related document is .
1 parent 170e30f commit 9011459

4 files changed

Lines changed: 10 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Mongoid::Includes 1.1.1 (2016-01-12) ##
2+
3+
* Fix bug with nested includes when the related document is `nil`.
4+
15
## Mongoid::Includes 1.1.0 (2015-11-04) ##
26

37
* Fix bug with optional polymorphic `belongs_to` relations where the name of the relation does not match an actual class name.

Gemfile.lock

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
mongoid_includes (1.1.0)
4+
mongoid_includes (1.1.1)
55
mongoid (>= 4.0.0, < 6.0.0)
66

77
GEM
@@ -87,3 +87,6 @@ DEPENDENCIES
8787
rspec-given (~> 3.5)
8888
yard
8989
yard-tomdoc
90+
91+
BUNDLED WITH
92+
1.11.2

lib/mongoid/includes/eager_load.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def preload_polymorphic(inclusion, docs)
4242
# includes by that property are processed as usual.
4343
def preload_nested(nested_inclusions, docs)
4444
nested_inclusions.group_by(&:from).each do |from, inclusions|
45-
preload(inclusions, docs.map(&from).flatten)
45+
preload(inclusions, docs.flat_map(&from).compact)
4646
end
4747
end
4848
end

lib/mongoid/includes/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ module Mongoid
55
module Includes
66

77
# Public: This library will attempt to follow semantic versioning (whatever that's supposed to be).
8-
VERSION = '1.1.0'
8+
VERSION = '1.1.1'
99
end
1010
end

0 commit comments

Comments
 (0)