diff options
| author | Apollon Oikonomopoulos <apoikos@debian.org> | 2018-03-22 12:04:55 +0200 |
|---|---|---|
| committer | Apollon Oikonomopoulos <apoikos@debian.org> | 2018-03-22 12:04:55 +0200 |
| commit | c49e99631589113663b1a3ac691870421965a315 (patch) | |
| tree | ac8127a5a6816f169a6656511bf131a35af2f74a /src/mongo/db/views/resolved_view.cpp | |
| parent | d982a88efa79f510c03f1c6c8c63360680ebbf88 (diff) | |
New upstream version 3.4.14upstream/3.4.14
Diffstat (limited to 'src/mongo/db/views/resolved_view.cpp')
| -rw-r--r-- | src/mongo/db/views/resolved_view.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/mongo/db/views/resolved_view.cpp b/src/mongo/db/views/resolved_view.cpp index d5f4faa7f68..f497cbbb9bd 100644 --- a/src/mongo/db/views/resolved_view.cpp +++ b/src/mongo/db/views/resolved_view.cpp @@ -62,7 +62,27 @@ ResolvedView ResolvedView::fromBSON(BSONObj commandResponseObj) { pipeline.push_back(item.Obj().getOwned()); } - return {ResolvedView(NamespaceString(viewDef["ns"].valueStringData()), pipeline)}; + BSONObj collationSpec; + if (auto collationElt = viewDef["collation"]) { + uassert(40639, + "View definition 'collation' field must be an object", + collationElt.type() == BSONType::Object); + collationSpec = collationElt.embeddedObject().getOwned(); + } + + return {NamespaceString(viewDef["ns"].valueStringData()), + std::move(pipeline), + std::move(collationSpec)}; +} + +BSONObj ResolvedView::toBSON() const { + BSONObjBuilder builder; + builder.append("ns", _namespace.ns()); + builder.append("pipeline", _pipeline); + if (!_defaultCollation.isEmpty()) { + builder.append("collation", _defaultCollation); + } + return builder.obj(); } StatusWith<BSONObj> ResolvedView::asExpandedViewAggregation( @@ -104,6 +124,13 @@ StatusWith<BSONObj> ResolvedView::asExpandedViewAggregation( aggregationBuilder.append("allowDiskUse", true); } + // Operations on a view must always use the default collation of the view. We must have already + // checked that if the user's request specifies a collation, it matches the collation of the + // view. + if (!_defaultCollation.isEmpty()) { + aggregationBuilder.append("collation", _defaultCollation); + } + return aggregationBuilder.obj(); } |
