Skip to content

Commit d077573

Browse files
authored
REP-5330 Fix deep index comparison. (#61)
This adds a $literal around the documents inserted into the $documents aggregation to allow for number-type discrepancies in index specifications. See the test case added here for why this is needed.
1 parent bfc46eb commit d077573

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

internal/verifier/migration_verifier.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -905,12 +905,10 @@ func (verifier *Verifier) doIndexSpecsMatch(ctx context.Context, srcSpec bson.Ra
905905
ctx,
906906
mongo.Pipeline{
907907
{{"$documents", []bson.D{
908-
{{"spec", srcSpec}},
909-
}}},
910-
911-
// Add the destination spec.
912-
{{"$addFields", bson.D{
913-
{"dstSpec", dstSpec},
908+
{
909+
{"spec", bson.D{{"$literal", srcSpec}}},
910+
{"dstSpec", bson.D{{"$literal", dstSpec}}},
911+
},
914912
}}},
915913

916914
{{"$unset", lo.Reduce(

internal/verifier/migration_verifier_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,19 @@ func (suite *IntegrationTestSuite) TestVerifierCompareIndexSpecs() {
10471047
shouldMatch: true,
10481048
},
10491049

1050+
{
1051+
label: "ignore number types, deep",
1052+
src: bson.D{
1053+
{"name", "testIndex"},
1054+
{"key", bson.M{"foo.bar": float64(123)}},
1055+
},
1056+
dst: bson.D{
1057+
{"name", "testIndex"},
1058+
{"key", bson.M{"foo.bar": 123}},
1059+
},
1060+
shouldMatch: true,
1061+
},
1062+
10501063
{
10511064
label: "find number differences",
10521065
src: bson.D{

0 commit comments

Comments
 (0)