From ffd8e5c8c4590b8129f6cafd18a15494bebc78ca Mon Sep 17 00:00:00 2001 From: Felipe Gasper Date: Wed, 27 Nov 2024 11:21:19 -0500 Subject: [PATCH 1/2] the fix --- internal/verifier/migration_verifier.go | 10 ++++------ internal/verifier/migration_verifier_test.go | 13 +++++++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/internal/verifier/migration_verifier.go b/internal/verifier/migration_verifier.go index 485b59c4..6320a273 100644 --- a/internal/verifier/migration_verifier.go +++ b/internal/verifier/migration_verifier.go @@ -905,12 +905,10 @@ func (verifier *Verifier) doIndexSpecsMatch(ctx context.Context, srcSpec bson.Ra ctx, mongo.Pipeline{ {{"$documents", []bson.D{ - {{"spec", srcSpec}}, - }}}, - - // Add the destination spec. - {{"$addFields", bson.D{ - {"dstSpec", dstSpec}, + { + {"spec", bson.D{{"$literal", srcSpec}}}, + {"dstSpec", bson.D{{"$literal", dstSpec}}}, + }, }}}, {{"$unset", lo.Reduce( diff --git a/internal/verifier/migration_verifier_test.go b/internal/verifier/migration_verifier_test.go index 6c83e3db..8089af14 100644 --- a/internal/verifier/migration_verifier_test.go +++ b/internal/verifier/migration_verifier_test.go @@ -1020,6 +1020,19 @@ func (suite *IntegrationTestSuite) TestVerifierCompareIndexSpecs() { shouldMatch: true, }, + { + label: "simple deep", + src: bson.D{ + {"name", "testIndex"}, + {"key", bson.M{"$foo.bar": 123}}, + }, + dst: bson.D{ + {"name", "testIndex"}, + {"key", bson.M{"$foo.bar": 123}}, + }, + shouldMatch: true, + }, + { label: "ignore `ns` field", src: bson.D{ From 905f802dad77edbde4d3f0e11498fbc690535177 Mon Sep 17 00:00:00 2001 From: Felipe Gasper Date: Wed, 27 Nov 2024 11:29:55 -0500 Subject: [PATCH 2/2] add test --- internal/verifier/migration_verifier_test.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/verifier/migration_verifier_test.go b/internal/verifier/migration_verifier_test.go index 8089af14..6fc76e7d 100644 --- a/internal/verifier/migration_verifier_test.go +++ b/internal/verifier/migration_verifier_test.go @@ -1021,41 +1021,41 @@ func (suite *IntegrationTestSuite) TestVerifierCompareIndexSpecs() { }, { - label: "simple deep", + label: "ignore `ns` field", src: bson.D{ {"name", "testIndex"}, - {"key", bson.M{"$foo.bar": 123}}, + {"key", bson.M{"foo": 123}}, + {"ns", "foo.bar"}, }, dst: bson.D{ {"name", "testIndex"}, - {"key", bson.M{"$foo.bar": 123}}, + {"key", bson.M{"foo": 123}}, }, shouldMatch: true, }, { - label: "ignore `ns` field", + label: "ignore number types", src: bson.D{ {"name", "testIndex"}, {"key", bson.M{"foo": 123}}, - {"ns", "foo.bar"}, }, dst: bson.D{ {"name", "testIndex"}, - {"key", bson.M{"foo": 123}}, + {"key", bson.M{"foo": float64(123)}}, }, shouldMatch: true, }, { - label: "ignore number types", + label: "ignore number types, deep", src: bson.D{ {"name", "testIndex"}, - {"key", bson.M{"foo": 123}}, + {"key", bson.M{"foo.bar": float64(123)}}, }, dst: bson.D{ {"name", "testIndex"}, - {"key", bson.M{"foo": float64(123)}}, + {"key", bson.M{"foo.bar": 123}}, }, shouldMatch: true, },