Skip to content

Commit 4ed4bef

Browse files
committed
WIP
1 parent f014b7d commit 4ed4bef

File tree

8 files changed

+32
-6
lines changed

8 files changed

+32
-6
lines changed

internal/integration/unified/collection_operation_execution.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@ func executeDeleteOne(ctx context.Context, operation *operation) (*operationResu
433433
opts.SetHint(hint)
434434
case "let":
435435
opts.SetLet(val.Document())
436+
case "rawData":
437+
opts.SetRawBucketsData(val.Boolean())
436438
default:
437439
return nil, fmt.Errorf("unrecognized deleteOne option %q", key)
438440
}
@@ -545,6 +547,8 @@ func executeDistinct(ctx context.Context, operation *operation) (*operationResul
545547
// ensured an analogue exists, extend "skippedTestDescriptions" to avoid
546548
// this error.
547549
return nil, fmt.Errorf("the maxTimeMS collection option is not supported")
550+
case "rawData":
551+
opts.SetRawBucketsData(val.Boolean())
548552
default:
549553
return nil, fmt.Errorf("unrecognized distinct option %q", key)
550554
}
@@ -842,6 +846,8 @@ func executeFindOneAndDelete(ctx context.Context, operation *operation) (*operat
842846
opts.SetSort(val.Document())
843847
case "let":
844848
opts.SetLet(val.Document())
849+
case "rawData":
850+
opts.SetRawBucketsData(val.Boolean())
845851
default:
846852
return nil, fmt.Errorf("unrecognized findOneAndDelete option %q", key)
847853
}
@@ -924,6 +930,8 @@ func executeFindOneAndReplace(ctx context.Context, operation *operation) (*opera
924930
opts.SetSort(val.Document())
925931
case "upsert":
926932
opts.SetUpsert(val.Boolean())
933+
case "rawData":
934+
opts.SetRawBucketsData(val.Boolean())
927935
default:
928936
return nil, fmt.Errorf("unrecognized findOneAndReplace option %q", key)
929937
}
@@ -1016,6 +1024,8 @@ func executeFindOneAndUpdate(ctx context.Context, operation *operation) (*operat
10161024
}
10171025
case "upsert":
10181026
opts.SetUpsert(val.Boolean())
1027+
case "rawData":
1028+
opts.SetRawBucketsData(val.Boolean())
10191029
default:
10201030
return nil, fmt.Errorf("unrecognized findOneAndUpdate option %q", key)
10211031
}
@@ -1062,6 +1072,8 @@ func executeInsertMany(ctx context.Context, operation *operation) (*operationRes
10621072
documents = bsonutil.RawToInterfaces(bsonutil.RawArrayToDocuments(val.Array())...)
10631073
case "ordered":
10641074
opts.SetOrdered(val.Boolean())
1075+
case "rawData":
1076+
opts.SetRawBucketsData(val.Boolean())
10651077
default:
10661078
return nil, fmt.Errorf("unrecognized insertMany option %q", key)
10671079
}
@@ -1112,6 +1124,8 @@ func executeInsertOne(ctx context.Context, operation *operation) (*operationResu
11121124
opts.SetBypassDocumentValidation(val.Boolean())
11131125
case "comment":
11141126
opts.SetComment(val)
1127+
case "rawData":
1128+
opts.SetRawBucketsData(val.Boolean())
11151129
default:
11161130
return nil, fmt.Errorf("unrecognized insertOne option %q", key)
11171131
}
@@ -1302,6 +1316,8 @@ func executeReplaceOne(ctx context.Context, operation *operation) (*operationRes
13021316
opts.SetUpsert(val.Boolean())
13031317
case "let":
13041318
opts.SetLet(val.Document())
1319+
case "rawData":
1320+
opts.SetRawBucketsData(val.Boolean())
13051321
default:
13061322
return nil, fmt.Errorf("unrecognized replaceOne option %q", key)
13071323
}

internal/integration/unified/crud_helpers.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ func createUpdateManyArguments(args bson.Raw) (*updateArguments, *options.Update
6767
}
6868
case "upsert":
6969
opts.SetUpsert(val.Boolean())
70+
case "rawData":
71+
opts.SetRawBucketsData(val.Boolean())
7072
default:
7173
return nil, nil, fmt.Errorf("unrecognized update option %q", key)
7274
}
@@ -125,6 +127,8 @@ func createUpdateOneArguments(args bson.Raw) (*updateArguments, *options.UpdateO
125127
opts.SetUpsert(val.Boolean())
126128
case "sort":
127129
opts.SetSort(val.Document())
130+
case "rawData":
131+
opts.SetRawBucketsData(val.Boolean())
128132
default:
129133
return nil, nil, fmt.Errorf("unrecognized update option %q", key)
130134
}

x/mongo/driver/operation/delete.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ func (d *Delete) command(dst []byte, desc description.SelectedServer) ([]byte, e
140140
if d.let != nil {
141141
dst = bsoncore.AppendDocumentElement(dst, "let", d.let)
142142
}
143-
if d.rawBucketsData != nil {
143+
// Set rawData for 8.2+ servers.
144+
if d.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) {
144145
dst = bsoncore.AppendBooleanElement(dst, "rawData", *d.rawBucketsData)
145146
}
146147
return dst, nil

x/mongo/driver/operation/distinct.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ func (d *Distinct) command(dst []byte, desc description.SelectedServer) ([]byte,
131131
if d.query != nil {
132132
dst = bsoncore.AppendDocumentElement(dst, "query", d.query)
133133
}
134-
if d.rawBucketsData != nil {
134+
// Set rawData for 8.2+ servers.
135+
if d.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) {
135136
dst = bsoncore.AppendBooleanElement(dst, "rawData", *d.rawBucketsData)
136137
}
137138
return dst, nil

x/mongo/driver/operation/find.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ func (f *Find) command(dst []byte, desc description.SelectedServer) ([]byte, err
192192
if f.tailable != nil {
193193
dst = bsoncore.AppendBooleanElement(dst, "tailable", *f.tailable)
194194
}
195-
if f.rawBucketsData != nil {
195+
// Set rawData for 8.2+ servers.
196+
if f.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) {
196197
dst = bsoncore.AppendBooleanElement(dst, "rawData", *f.rawBucketsData)
197198
}
198199
return dst, nil

x/mongo/driver/operation/find_and_modify.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ func (fam *FindAndModify) command(dst []byte, desc description.SelectedServer) (
212212
if fam.let != nil {
213213
dst = bsoncore.AppendDocumentElement(dst, "let", fam.let)
214214
}
215-
if fam.rawBucketsData != nil {
215+
// Set rawData for 8.2+ servers.
216+
if fam.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) {
216217
dst = bsoncore.AppendBooleanElement(dst, "rawData", *fam.rawBucketsData)
217218
}
218219

x/mongo/driver/operation/insert.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ func (i *Insert) command(dst []byte, desc description.SelectedServer) ([]byte, e
133133
if i.ordered != nil {
134134
dst = bsoncore.AppendBooleanElement(dst, "ordered", *i.ordered)
135135
}
136-
if i.rawBucketsData != nil {
136+
// Set rawData for 8.2+ servers.
137+
if i.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) {
137138
dst = bsoncore.AppendBooleanElement(dst, "rawData", *i.rawBucketsData)
138139
}
139140
return dst, nil

x/mongo/driver/operation/update.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ func (u *Update) command(dst []byte, desc description.SelectedServer) ([]byte, e
204204
if u.let != nil {
205205
dst = bsoncore.AppendDocumentElement(dst, "let", u.let)
206206
}
207-
if u.rawBucketsData != nil {
207+
// Set rawData for 8.2+ servers.
208+
if u.rawBucketsData != nil && desc.WireVersion != nil && driverutil.VersionRangeIncludes(*desc.WireVersion, 27) {
208209
dst = bsoncore.AppendBooleanElement(dst, "rawData", *u.rawBucketsData)
209210
}
210211

0 commit comments

Comments
 (0)