Skip to content

Commit

Permalink
Add comment about empty bulk write requests
Browse files Browse the repository at this point in the history
  • Loading branch information
felixmo committed May 17, 2024
1 parent 2613693 commit 69d2199
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/mongo/bulk_write.rb
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,12 @@ def can_hint?(connection)
# and some which are not), in which case the driver expects the server to
# fail the operation with an error.
#
# Raise an ArgumentError if requests is empty.
#
# @raise [ Error::InvalidUpdateDocument, Error::InvalidReplacementDocument,
# ArgumentError ]
# @raise [ Error::InvalidUpdateDocument, Error::InvalidReplacementDocument ]
# if the document is invalid.
def validate_requests!
# requests_empty = true
@requests.each do |req|
# requests_empty = false
if op = req.keys.first
if [:update_one, :update_many].include?(op)
if doc = maybe_first(req.dig(op, :update))
Expand All @@ -357,6 +356,9 @@ def validate_requests!
end
end
end
# Sometimes we send empty requests so don't raise an error here until we fix that
# end.tap do
# raise ArgumentError, "Bulk write requests cannot be empty" if requests_empty
end
end

Expand Down

0 comments on commit 69d2199

Please sign in to comment.