diff options
author | Justin Seyster <justin.seyster@mongodb.com> | 2019-09-27 00:19:54 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-09-27 00:19:54 +0000 |
commit | 81deec4580a95475ed906ec5840290e003663b38 (patch) | |
tree | b086c0677b48ac1aded3e5ee7f6a554fa9617e33 | |
parent | ba9670e4c6d3aa62db20501317457af99049570c (diff) | |
download | mongo-81deec4580a95475ed906ec5840290e003663b38.tar.gz |
SERVER-42649 Disambiguate Value constructor
The Xcode 10.2 Clang considers {Value(), Value()} constructors to be ambiguous:
src/mongo/dbtests/query_stage_sort_key_generator.cpp:137:11: error: call to constructor of 'mongo::Value' is ambiguous
Value expectedOut({Value(99), Value(16)});
^ ~~~~~~~~~~~~~~~~~~~~~~
src/mongo/db/pipeline/value.h:103:14: note: candidate constructor
explicit Value(const std::string& value) : _storage(String, StringData(value)) {}
^
src/mongo/db/pipeline/value.h:109:14: note: candidate constructor
explicit Value(std::vector<Value> vec)
This patch uses an explicit std::vector<Value> constructor to fix macOS compiles.
-rw-r--r-- | src/mongo/db/pipeline/expression_test.cpp | 2 | ||||
-rw-r--r-- | src/mongo/dbtests/query_stage_sort_key_generator.cpp | 14 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/mongo/db/pipeline/expression_test.cpp b/src/mongo/db/pipeline/expression_test.cpp index 3043399787a..5d30bd58f4a 100644 --- a/src/mongo/db/pipeline/expression_test.cpp +++ b/src/mongo/db/pipeline/expression_test.cpp @@ -6199,7 +6199,7 @@ TEST(ExpressionMetaTest, ExpressionMetaSortKey) { ExpressionMeta::parse(expCtx, expr.firstElement(), expCtx->variablesParseState); MutableDocument doc; - Value sortKey = Value({Value(1), Value(2)}); + Value sortKey = Value(std::vector<Value>{Value(1), Value(2)}); doc.metadata().setSortKey(sortKey, /* isSingleElementSortKey = */ false); Value val = expressionMeta->evaluate(doc.freeze(), &expCtx->variables); ASSERT_BSONOBJ_EQ(val.getDocument().toBson(), BSON("" << 1 << "" << 2)); diff --git a/src/mongo/dbtests/query_stage_sort_key_generator.cpp b/src/mongo/dbtests/query_stage_sort_key_generator.cpp index 6ee9b1ba86c..00e3f40d92c 100644 --- a/src/mongo/dbtests/query_stage_sort_key_generator.cpp +++ b/src/mongo/dbtests/query_stage_sort_key_generator.cpp @@ -134,21 +134,21 @@ TEST(SortKeyGeneratorStageTest, SortKeyString) { TEST(SortKeyGeneratorStageTest, SortKeyCompound) { Value actualOut = extractSortKey("{a: 1, b: 1}", "{_id: 0, z: 'thing1', a: 99, c: {a: 4}, b: 16}", nullptr); - Value expectedOut({Value(99), Value(16)}); + Value expectedOut(std::vector<Value>{Value(99), Value(16)}); ASSERT_VALUE_EQ(actualOut, expectedOut); } TEST(SortKeyGeneratorStageTest, SortKeyEmbedded) { Value actualOut = extractSortKey( "{'c.a': 1, b: 1}", "{_id: 0, z: 'thing1', a: 99, c: {a: 4}, b: 16}", nullptr); - Value expectedOut = Value({Value(4), Value(16)}); + Value expectedOut = Value(std::vector<Value>{Value(4), Value(16)}); ASSERT_VALUE_EQ(actualOut, expectedOut); } TEST(SortKeyGeneratorStageTest, SortKeyArray) { Value actualOut = extractSortKey( "{'c': 1, b: 1}", "{_id: 0, z: 'thing1', a: 99, c: [2, 4, 1], b: 16}", nullptr); - Value expectedOut({Value(1), Value(16)}); + Value expectedOut(std::vector<Value>{Value(1), Value(16)}); ASSERT_VALUE_EQ(actualOut, expectedOut); } @@ -176,7 +176,7 @@ TEST(SortKeyGeneratorStageTest, SortKeyCoveredCompound) { "{a: 1, c: 1}", IndexKeyDatum(BSON("a" << 1 << "c" << 1), BSON("" << 5 << "" << 6), 0, SnapshotId{}), collator); - Value expectedOut({Value(5), Value(6)}); + Value expectedOut(std::vector<Value>{Value(5), Value(6)}); ASSERT_VALUE_EQ(actualOut, expectedOut); } @@ -188,7 +188,7 @@ TEST(SortKeyGeneratorStageTest, SortKeyCoveredCompound2) { 0, SnapshotId{}), collator); - Value expectedOut({Value(5), Value(6)}); + Value expectedOut(std::vector<Value>{Value(5), Value(6)}); ASSERT_VALUE_EQ(actualOut, expectedOut); } @@ -201,7 +201,7 @@ TEST(SortKeyGeneratorStageTest, SortKeyCoveredCompound3) { 0, SnapshotId{}), collator); - Value expectedOut({Value(6), Value(4)}); + Value expectedOut(std::vector<Value>{Value(6), Value(4)}); ASSERT_VALUE_EQ(actualOut, expectedOut); } @@ -251,7 +251,7 @@ TEST(SortKeyGeneratorStageTest, SortKeyGenerationForArraysRespectsCompoundOrderi Value actualOut = extractSortKey("{'a.b': 1, 'a.c': -1}", "{_id: 0, a: [{b: 1, c: 0}, {b: 0, c: 3}, {b: 0, c: 1}]}", nullptr); - Value expectedOut({Value(0), Value(3)}); + Value expectedOut(std::vector<Value>{Value(0), Value(3)}); ASSERT_VALUE_EQ(actualOut, expectedOut); } |