-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98bdf06
commit 9ccc394
Showing
6 changed files
with
886 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Replace usage of $pushAll with $push + $each for MongoDB 3.6 support. | ||
# Note that some of this is done in the `atomic.rb` patch as well. | ||
|
||
if Mongoid::VERSION =~ /\A3\./ | ||
|
||
module Mongoid | ||
module Relations | ||
module Embedded | ||
module Batchable | ||
def batch_insert(docs) | ||
execute_batch_insert(docs, "$push", true) | ||
end | ||
|
||
def execute_batch_insert(docs, operation, use_each = false) | ||
self.inserts_valid = true | ||
inserts = pre_process_batch_insert(docs) | ||
if insertable? | ||
collection.find(selector).update( | ||
positionally(selector, operation => { path => use_each ? { '$each' => inserts } : inserts }) | ||
) | ||
post_process_batch_insert(docs) | ||
end | ||
inserts | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
module Mongoid | ||
module Atomic | ||
class Modifiers < Hash | ||
def push(modifications) | ||
modifications.each_pair do |field, value| | ||
push_fields[field] = field | ||
mods = push_conflict?(field) ? conflicting_pushes : pushes | ||
add_each_operation(mods, field, value) | ||
end | ||
end | ||
|
||
def add_each_operation(mods, field, value) | ||
value = Array.wrap(value) | ||
if mods.has_key?(field) | ||
value.each do |val| | ||
mods[field]["$each"].push(val) | ||
end | ||
else | ||
mods[field] = { "$each" => value } | ||
end | ||
end | ||
|
||
def conflicting_pushes | ||
conflicts["$push"] ||= {} | ||
end | ||
|
||
def pushes | ||
self["$push"] ||= {} | ||
end | ||
end | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module MongoidMonkey | ||
VERSION = '0.3.1' | ||
VERSION = '0.3.2' | ||
end |
Oops, something went wrong.