Skip to content

Commit 2c55e59

Browse files
committed
PYTHON-4925 Revert multi change
1 parent 1608aca commit 2c55e59

File tree

4 files changed

+24
-28
lines changed

4 files changed

+24
-28
lines changed

pymongo/asynchronous/bulk.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,7 @@ def add_update(
149149
) -> None:
150150
"""Create an update document and add it to the list of ops."""
151151
validate_ok_for_update(update)
152-
cmd: dict[str, Any] = {"q": selector, "u": update}
153-
if multi:
154-
cmd["multi"] = multi
155-
# A bulk_write containing an update_many is not retryable.
156-
self.is_retryable = False
152+
cmd: dict[str, Any] = {"q": selector, "u": update, "multi": multi}
157153
if upsert is not None:
158154
cmd["upsert"] = upsert
159155
if collation is not None:
@@ -168,6 +164,9 @@ def add_update(
168164
if sort is not None:
169165
self.uses_sort = True
170166
cmd["sort"] = sort
167+
if multi:
168+
# A bulk_write containing an update_many is not retryable.
169+
self.is_retryable = False
171170
self.ops.append((_UPDATE, cmd))
172171

173172
def add_replace(

pymongo/asynchronous/client_bulk.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,8 @@ def add_update(
150150
"update": -1,
151151
"filter": selector,
152152
"updateMods": update,
153+
"multi": multi,
153154
}
154-
if multi:
155-
# A bulk_write containing an update_many is not retryable.
156-
self.is_retryable = False
157-
cmd["multi"] = multi
158155
if upsert is not None:
159156
cmd["upsert"] = upsert
160157
if array_filters is not None:
@@ -167,6 +164,9 @@ def add_update(
167164
cmd["collation"] = collation
168165
if sort is not None:
169166
cmd["sort"] = sort
167+
if multi:
168+
# A bulk_write containing an update_many is not retryable.
169+
self.is_retryable = False
170170
self.ops.append(("update", cmd))
171171
self.namespaces.append(namespace)
172172
self.total_ops += 1
@@ -211,16 +211,15 @@ def add_delete(
211211
hint: Union[str, dict[str, Any], None] = None,
212212
) -> None:
213213
"""Create a delete document and add it to the list of ops."""
214-
cmd = {"delete": -1, "filter": selector}
215-
if multi:
216-
cmd["multi"] = multi
217-
# A bulk_write containing an update_many is not retryable.
218-
self.is_retryable = False
214+
cmd = {"delete": -1, "filter": selector, "multi": multi}
219215
if hint is not None:
220216
cmd["hint"] = hint
221217
if collation is not None:
222218
self.uses_collation = True
223219
cmd["collation"] = collation
220+
if multi:
221+
# A bulk_write containing an update_many is not retryable.
222+
self.is_retryable = False
224223
self.ops.append(("delete", cmd))
225224
self.namespaces.append(namespace)
226225
self.total_ops += 1

pymongo/synchronous/bulk.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,7 @@ def add_update(
149149
) -> None:
150150
"""Create an update document and add it to the list of ops."""
151151
validate_ok_for_update(update)
152-
cmd: dict[str, Any] = {"q": selector, "u": update}
153-
if multi:
154-
cmd["multi"] = multi
155-
# A bulk_write containing an update_many is not retryable.
156-
self.is_retryable = False
152+
cmd: dict[str, Any] = {"q": selector, "u": update, "multi": multi}
157153
if upsert is not None:
158154
cmd["upsert"] = upsert
159155
if collation is not None:
@@ -168,6 +164,9 @@ def add_update(
168164
if sort is not None:
169165
self.uses_sort = True
170166
cmd["sort"] = sort
167+
if multi:
168+
# A bulk_write containing an update_many is not retryable.
169+
self.is_retryable = False
171170
self.ops.append((_UPDATE, cmd))
172171

173172
def add_replace(

pymongo/synchronous/client_bulk.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,8 @@ def add_update(
150150
"update": -1,
151151
"filter": selector,
152152
"updateMods": update,
153+
"multi": multi,
153154
}
154-
if multi:
155-
# A bulk_write containing an update_many is not retryable.
156-
self.is_retryable = False
157-
cmd["multi"] = multi
158155
if upsert is not None:
159156
cmd["upsert"] = upsert
160157
if array_filters is not None:
@@ -167,6 +164,9 @@ def add_update(
167164
cmd["collation"] = collation
168165
if sort is not None:
169166
cmd["sort"] = sort
167+
if multi:
168+
# A bulk_write containing an update_many is not retryable.
169+
self.is_retryable = False
170170
self.ops.append(("update", cmd))
171171
self.namespaces.append(namespace)
172172
self.total_ops += 1
@@ -211,16 +211,15 @@ def add_delete(
211211
hint: Union[str, dict[str, Any], None] = None,
212212
) -> None:
213213
"""Create a delete document and add it to the list of ops."""
214-
cmd = {"delete": -1, "filter": selector}
215-
if multi:
216-
cmd["multi"] = multi
217-
# A bulk_write containing an update_many is not retryable.
218-
self.is_retryable = False
214+
cmd = {"delete": -1, "filter": selector, "multi": multi}
219215
if hint is not None:
220216
cmd["hint"] = hint
221217
if collation is not None:
222218
self.uses_collation = True
223219
cmd["collation"] = collation
220+
if multi:
221+
# A bulk_write containing an update_many is not retryable.
222+
self.is_retryable = False
224223
self.ops.append(("delete", cmd))
225224
self.namespaces.append(namespace)
226225
self.total_ops += 1

0 commit comments

Comments
 (0)