diff options
Diffstat (limited to 'src/mongo/db/pipeline/value.cpp')
-rw-r--r-- | src/mongo/db/pipeline/value.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/mongo/db/pipeline/value.cpp b/src/mongo/db/pipeline/value.cpp index b804adaf797..e9bd0d4ccc2 100644 --- a/src/mongo/db/pipeline/value.cpp +++ b/src/mongo/db/pipeline/value.cpp @@ -151,7 +151,8 @@ Document ValueStorage::getDocument() const { } // not in header because document is fwd declared -Value::Value(const BSONObj& obj) : _storage(Object, Document(obj)) {} +Value::Value(const BSONObj& obj) : _storage(Object, Document(obj.getOwned())) {} +Value::Value(const Document& doc) : _storage(Object, doc.isOwned() ? doc : doc.getOwned()) {} Value::Value(const BSONElement& elem) : _storage(elem.type()) { switch (elem.type()) { @@ -174,7 +175,7 @@ Value::Value(const BSONElement& elem) : _storage(elem.type()) { break; case Object: { - _storage.putDocument(Document(elem.embeddedObject())); + _storage.putDocument(Document(elem.embeddedObject().getOwned())); break; } |