@@ -191,6 +191,8 @@ type modelBatches struct {
191191 writeErrors map [int ]WriteError
192192}
193193
194+ var _ driver.OperationBatches = & modelBatches {}
195+
194196func (mb * modelBatches ) IsOrdered () * bool {
195197 return & mb .ordered
196198}
@@ -209,7 +211,7 @@ func (mb *modelBatches) Size() int {
209211 return len (mb .models ) - mb .offset
210212}
211213
212- func (mb * modelBatches ) AppendBatchSequence (dst []byte , maxCount , maxDocSize , totalSize int ) (int , []byte , error ) {
214+ func (mb * modelBatches ) AppendBatchSequence (dst []byte , maxCount , totalSize int ) (int , []byte , error ) {
213215 fn := functionSet {
214216 appendStart : func (dst []byte , identifier string ) (int32 , []byte ) {
215217 var idx int32
@@ -228,10 +230,10 @@ func (mb *modelBatches) AppendBatchSequence(dst []byte, maxCount, maxDocSize, to
228230 return dst
229231 },
230232 }
231- return mb .appendBatches (fn , dst , maxCount , maxDocSize , totalSize )
233+ return mb .appendBatches (fn , dst , maxCount , totalSize )
232234}
233235
234- func (mb * modelBatches ) AppendBatchArray (dst []byte , maxCount , maxDocSize , totalSize int ) (int , []byte , error ) {
236+ func (mb * modelBatches ) AppendBatchArray (dst []byte , maxCount , totalSize int ) (int , []byte , error ) {
235237 fn := functionSet {
236238 appendStart : bsoncore .AppendArrayElementStart ,
237239 appendDocument : bsoncore .AppendDocumentElement ,
@@ -240,7 +242,7 @@ func (mb *modelBatches) AppendBatchArray(dst []byte, maxCount, maxDocSize, total
240242 return dst
241243 },
242244 }
243- return mb .appendBatches (fn , dst , maxCount , maxDocSize , totalSize )
245+ return mb .appendBatches (fn , dst , maxCount , totalSize )
244246}
245247
246248type functionSet struct {
@@ -249,7 +251,7 @@ type functionSet struct {
249251 updateLength func ([]byte , int32 , int32 ) []byte
250252}
251253
252- func (mb * modelBatches ) appendBatches (fn functionSet , dst []byte , maxCount , maxDocSize , totalSize int ) (int , []byte , error ) {
254+ func (mb * modelBatches ) appendBatches (fn functionSet , dst []byte , maxCount , totalSize int ) (int , []byte , error ) {
253255 if mb .Size () == 0 {
254256 return 0 , dst , io .EOF
255257 }
@@ -269,8 +271,6 @@ func (mb *modelBatches) appendBatches(fn functionSet, dst []byte, maxCount, maxD
269271 }
270272
271273 canRetry := true
272- checkSize := true
273-
274274 l := len (dst )
275275
276276 opsIdx , dst := fn .appendStart (dst , "ops" )
@@ -291,13 +291,11 @@ func (mb *modelBatches) appendBatches(fn functionSet, dst []byte, maxCount, maxD
291291 var err error
292292 switch model := mb .models [i ].model .(type ) {
293293 case * ClientInsertOneModel :
294- checkSize = false
295294 mb .cursorHandlers = append (mb .cursorHandlers , mb .appendInsertResult )
296295 var id interface {}
297296 id , doc , err = (& clientInsertDoc {
298297 namespace : nsIdx ,
299298 document : model .Document ,
300- sizeLimit : maxDocSize ,
301299 }).marshal (mb .client .bsonOpts , mb .client .registry )
302300 if err != nil {
303301 break
@@ -331,7 +329,6 @@ func (mb *modelBatches) appendBatches(fn functionSet, dst []byte, maxCount, maxD
331329 checkDollarKey : true ,
332330 }).marshal (mb .client .bsonOpts , mb .client .registry )
333331 case * ClientReplaceOneModel :
334- checkSize = false
335332 mb .cursorHandlers = append (mb .cursorHandlers , mb .appendUpdateResult )
336333 doc , err = (& clientUpdateDoc {
337334 namespace : nsIdx ,
@@ -343,7 +340,6 @@ func (mb *modelBatches) appendBatches(fn functionSet, dst []byte, maxCount, maxD
343340 upsert : model .Upsert ,
344341 multi : false ,
345342 checkDollarKey : false ,
346- sizeLimit : maxDocSize ,
347343 }).marshal (mb .client .bsonOpts , mb .client .registry )
348344 case * ClientDeleteOneModel :
349345 mb .cursorHandlers = append (mb .cursorHandlers , mb .appendDeleteResult )
@@ -371,9 +367,6 @@ func (mb *modelBatches) appendBatches(fn functionSet, dst []byte, maxCount, maxD
371367 return 0 , nil , err
372368 }
373369 length := len (doc )
374- if maxDocSize > 0 && length > maxDocSize + 16 * 1024 {
375- return 0 , nil , driver .ErrDocumentTooLarge
376- }
377370 if ! exists {
378371 length += len (ns )
379372 }
@@ -398,9 +391,6 @@ func (mb *modelBatches) appendBatches(fn functionSet, dst []byte, maxCount, maxD
398391 dst = fn .updateLength (dst , opsIdx , int32 (len (dst [opsIdx :])))
399392 nsDst = fn .updateLength (nsDst , nsIdx , int32 (len (nsDst [nsIdx :])))
400393 dst = append (dst , nsDst ... )
401- if checkSize && maxDocSize > 0 && len (dst )- l > maxDocSize + 16 * 1024 {
402- return 0 , nil , driver .ErrDocumentTooLarge
403- }
404394
405395 mb .retryMode = driver .RetryNone
406396 if mb .client .retryWrites && canRetry {
@@ -584,8 +574,6 @@ func (mb *modelBatches) appendUpdateResult(cur *cursorInfo, raw bson.Raw) bool {
584574type clientInsertDoc struct {
585575 namespace int
586576 document interface {}
587-
588- sizeLimit int
589577}
590578
591579func (d * clientInsertDoc ) marshal (bsonOpts * options.BSONOptions , registry * bson.Registry ) (interface {}, bsoncore.Document , error ) {
@@ -596,9 +584,6 @@ func (d *clientInsertDoc) marshal(bsonOpts *options.BSONOptions, registry *bson.
596584 if err != nil {
597585 return nil , nil , err
598586 }
599- if d .sizeLimit > 0 && len (f ) > d .sizeLimit {
600- return nil , nil , driver .ErrDocumentTooLarge
601- }
602587 var id interface {}
603588 f , id , err = ensureID (f , bson .NilObjectID , bsonOpts , registry )
604589 if err != nil {
@@ -619,8 +604,6 @@ type clientUpdateDoc struct {
619604 upsert * bool
620605 multi bool
621606 checkDollarKey bool
622-
623- sizeLimit int
624607}
625608
626609func (d * clientUpdateDoc ) marshal (bsonOpts * options.BSONOptions , registry * bson.Registry ) (bsoncore.Document , error ) {
@@ -641,9 +624,6 @@ func (d *clientUpdateDoc) marshal(bsonOpts *options.BSONOptions, registry *bson.
641624 if err != nil {
642625 return nil , err
643626 }
644- if d .sizeLimit > 0 && len (u .Data ) > d .sizeLimit {
645- return nil , driver .ErrDocumentTooLarge
646- }
647627 doc = bsoncore .AppendValueElement (doc , "updateMods" , u )
648628 doc = bsoncore .AppendBooleanElement (doc , "multi" , d .multi )
649629
0 commit comments