File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change 24
24
import datetime
25
25
import random
26
26
import struct
27
- from collections import ChainMap
28
27
from io import BytesIO as _BytesIO
29
28
from typing import (
30
29
TYPE_CHECKING ,
@@ -1117,14 +1116,14 @@ def _check_doc_size_limits(
1117
1116
op_doc [op_type ] = ns_info [namespace ] # type: ignore[index]
1118
1117
1119
1118
# Since the data document itself is nested within the insert document
1120
- # it won't be automatically re-ordered by the BSON conversion.
1121
- # We use ChainMap here to make the _id field the first field instead .
1119
+ # it won't be automatically re-ordered by the BSON conversion, so we need
1120
+ # to encode it directly as a top-level document first .
1122
1121
doc_to_encode = op_doc
1123
1122
if real_op_type == "insert" :
1124
1123
doc = op_doc ["document" ]
1125
1124
if not isinstance (doc , RawBSONDocument ):
1126
1125
doc_to_encode = op_doc .copy () # type: ignore[attr-defined] # Shallow copy
1127
- doc_to_encode ["document" ] = ChainMap ( doc , { "_id" : doc [ "_id" ]} ) # type: ignore[index]
1126
+ doc_to_encode ["document" ] = RawBSONDocument ( _dict_to_bson ( doc , False , opts ) ) # type: ignore[index]
1128
1127
1129
1128
# Encode current operation doc and, if newly added, namespace doc.
1130
1129
op_doc_encoded = _dict_to_bson (doc_to_encode , False , opts )
You can’t perform that action at this time.
0 commit comments