summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands
diff options
context:
space:
mode:
authorTess Avitabile <tess.avitabile@mongodb.com>2016-04-19 10:36:40 -0400
committerTess Avitabile <tess.avitabile@mongodb.com>2016-04-21 10:42:37 -0400
commit9dcb30e21814a36c43a795f9d8d2b5a117a99a31 (patch)
tree520496e828a2878342aee20956a50d0941369ea9 /src/mongo/db/commands
parentf54df32567a71986b961c99da5de9cf1f5c46670 (diff)
downloadmongo-9dcb30e21814a36c43a795f9d8d2b5a117a99a31.tar.gz
SERVER-23473 Add collation parameter to the distinct command
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r--src/mongo/db/commands/distinct.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mongo/db/commands/distinct.cpp b/src/mongo/db/commands/distinct.cpp
index 16ea9564a64..10fe2533043 100644
--- a/src/mongo/db/commands/distinct.cpp
+++ b/src/mongo/db/commands/distinct.cpp
@@ -63,6 +63,7 @@ namespace {
const char kKeyField[] = "key";
const char kQueryField[] = "query";
+const char kCollationField[] = "collation";
} // namespace
@@ -130,6 +131,21 @@ public:
}
}
+ // Extract the collation field, if it exists.
+ // TODO SERVER-23473: Pass this collation spec object down so that it can be converted into
+ // a CollatorInterface.
+ BSONObj collation;
+ if (BSONElement collationElt = cmdObj[kCollationField]) {
+ if (collationElt.type() != BSONType::Object) {
+ return Status(ErrorCodes::TypeMismatch,
+ str::stream() << "\"" << kCollationField
+ << "\" had the wrong type. Expected "
+ << typeName(BSONType::Object) << ", found "
+ << typeName(collationElt.type()));
+ }
+ collation = collationElt.embeddedObject();
+ }
+
auto executor = getExecutorDistinct(
txn, collection, ns, query, key, isExplain, PlanExecutor::YIELD_AUTO);
if (!executor.isOK()) {