diff options
author | Svilen Mihaylov <svilen.mihaylov@mongodb.com> | 2022-04-25 20:33:50 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-04-25 21:03:46 +0000 |
commit | ab3f0134f86b7c7974e61f3af80a9fd549a15e33 (patch) | |
tree | cdeec6ea5876e4e2e433b21424c5a5e3faa6d4af /src/mongo/db | |
parent | f9c7dc1cc2e3a3109a5c4e37b2615ad78f3cf7ab (diff) | |
download | mongo-ab3f0134f86b7c7974e61f3af80a9fd549a15e33.tar.gz |
SERVER-65928 Fix behavior of $in with null and missing
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/pipeline/abt/match_expression_visitor.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/mongo/db/pipeline/abt/match_expression_visitor.cpp b/src/mongo/db/pipeline/abt/match_expression_visitor.cpp index 86f5997adf2..d364b68e2c5 100644 --- a/src/mongo/db/pipeline/abt/match_expression_visitor.cpp +++ b/src/mongo/db/pipeline/abt/match_expression_visitor.cpp @@ -153,12 +153,15 @@ public: } // Additively compose equality comparisons, creating one for each constant in 'equalities'. - auto [firstTag, firstVal] = convertFrom(Value(equalities[0])); - ABT result = make<PathCompare>(Operations::Eq, make<Constant>(firstTag, firstVal)); - for (size_t i = 1; i < equalities.size(); i++) { - auto [tag, val] = convertFrom(Value(equalities[i])); - result = make<PathComposeA>( - std::move(result), make<PathCompare>(Operations::Eq, make<Constant>(tag, val))); + ABT result = make<PathIdentity>(); + for (const auto& pred : equalities) { + const auto [tag, val] = convertFrom(Value(pred)); + if (tag == sbe::value::TypeTags::Null) { + // Handle null and missing. + maybeComposePath<PathComposeA>(result, make<PathDefault>(Constant::boolean(true))); + } + maybeComposePath<PathComposeA>( + result, make<PathCompare>(Operations::Eq, make<Constant>(tag, val))); } // The path can be empty if we are within an $elemMatch. |