summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline
diff options
context:
space:
mode:
authorSiyuan Zhou <siyuan.zhou@mongodb.com>2017-08-10 14:09:11 -0400
committerSiyuan Zhou <siyuan.zhou@mongodb.com>2017-08-15 15:29:05 -0400
commit13b5a981c0118704c91881669444ae66d0261878 (patch)
tree83b597394046ba8b3f3d29136524598a7ff95a2d /src/mongo/db/pipeline
parentc6d8efbf92ed0f3fd20d05557cfbe77d0c7934b4 (diff)
downloadmongo-13b5a981c0118704c91881669444ae66d0261878.tar.gz
SERVER-30512 Omit fullDocument in change stream if it's null unless updateLookup is specified explicitly.
Diffstat (limited to 'src/mongo/db/pipeline')
-rw-r--r--src/mongo/db/pipeline/document_source_change_stream.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_change_stream_test.cpp6
-rw-r--r--src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp13
3 files changed, 7 insertions, 14 deletions
diff --git a/src/mongo/db/pipeline/document_source_change_stream.cpp b/src/mongo/db/pipeline/document_source_change_stream.cpp
index 973e0507f73..1eda922c388 100644
--- a/src/mongo/db/pipeline/document_source_change_stream.cpp
+++ b/src/mongo/db/pipeline/document_source_change_stream.cpp
@@ -296,7 +296,7 @@ Document DocumentSourceChangeStream::Transformation::applyTransformation(const D
// Non-replace updates have the _id in field "o2".
Value documentId = id.missing() ? input.getNestedField("o2._id") : id;
StringData operationType;
- Value fullDocument = Value(BSONNULL);
+ Value fullDocument;
Value updateDescription;
// Deal with CRUD operations and commands.
diff --git a/src/mongo/db/pipeline/document_source_change_stream_test.cpp b/src/mongo/db/pipeline/document_source_change_stream_test.cpp
index 6d558d973d5..158de011548 100644
--- a/src/mongo/db/pipeline/document_source_change_stream_test.cpp
+++ b/src/mongo/db/pipeline/document_source_change_stream_test.cpp
@@ -216,7 +216,6 @@ TEST_F(ChangeStreamStageTest, TransformUpdateFields) {
Document expectedUpdateField{
{DSChangeStream::kIdField, makeResumeToken(ts, nss, 1)},
{DSChangeStream::kOperationTypeField, DSChangeStream::kUpdateOpType},
- {DSChangeStream::kFullDocumentField, BSONNULL},
{DSChangeStream::kNamespaceField, D{{"db", nss.db()}, {"coll", nss.coll()}}},
{DSChangeStream::kDocumentKeyField, D{{"_id", 1}}},
{
@@ -233,7 +232,6 @@ TEST_F(ChangeStreamStageTest, TransformRemoveFields) {
Document expectedRemoveField{
{DSChangeStream::kIdField, makeResumeToken(ts, nss, 1)},
{DSChangeStream::kOperationTypeField, DSChangeStream::kUpdateOpType},
- {DSChangeStream::kFullDocumentField, BSONNULL},
{DSChangeStream::kNamespaceField, D{{"db", nss.db()}, {"coll", nss.coll()}}},
{DSChangeStream::kDocumentKeyField, D{{"_id", 1}}},
{
@@ -262,7 +260,6 @@ TEST_F(ChangeStreamStageTest, TransformDelete) {
Document expectedDelete{
{DSChangeStream::kIdField, makeResumeToken(ts, nss, 1)},
{DSChangeStream::kOperationTypeField, DSChangeStream::kDeleteOpType},
- {DSChangeStream::kFullDocumentField, BSONNULL},
{DSChangeStream::kNamespaceField, D{{"db", nss.db()}, {"coll", nss.coll()}}},
{DSChangeStream::kDocumentKeyField, D{{"_id", 1}}},
};
@@ -290,7 +287,6 @@ TEST_F(ChangeStreamStageTest, TransformInvalidate) {
Document expectedInvalidate{
{DSChangeStream::kIdField, makeResumeToken(ts, nss.getCommandNS())},
{DSChangeStream::kOperationTypeField, DSChangeStream::kInvalidateOpType},
- {DSChangeStream::kFullDocumentField, BSONNULL},
};
for (auto& entry : {dropColl, dropDB, rename}) {
checkTransformation(entry, expectedInvalidate);
@@ -324,7 +320,6 @@ TEST_F(ChangeStreamStageTest, TransformInvalidateRenameDropTarget) {
Document expectedInvalidate{
{DSChangeStream::kIdField, makeResumeToken(ts, otherColl.getCommandNS())},
{DSChangeStream::kOperationTypeField, DSChangeStream::kInvalidateOpType},
- {DSChangeStream::kFullDocumentField, BSONNULL},
};
checkTransformation(rename, expectedInvalidate);
}
@@ -401,7 +396,6 @@ TEST_F(ChangeStreamStageTest, CloseCursorOnInvalidateEntries) {
Document expectedInvalidate{
{DSChangeStream::kIdField, makeResumeToken(ts, nss.getCommandNS())},
{DSChangeStream::kOperationTypeField, DSChangeStream::kInvalidateOpType},
- {DSChangeStream::kFullDocumentField, BSONNULL},
};
auto next = closeCursor->getNext();
diff --git a/src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp b/src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp
index 0e156287125..c1d0c6d10fa 100644
--- a/src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp
+++ b/src/mongo/db/pipeline/document_source_lookup_change_post_image_test.cpp
@@ -219,12 +219,11 @@ TEST_F(DocumentSourceLookupChangePostImageTest, ShouldPropagatePauses) {
auto mockLocalSource = DocumentSourceMock::create(
{Document{{"documentKey", Document{{"_id", 0}}},
{"operationType", "insert"_sd},
- {"fullDocument", Document{{"_id", 0}}},
- {"ns", Document{{"db", expCtx->ns.db()}, {"coll", expCtx->ns.coll()}}}},
+ {"ns", Document{{"db", expCtx->ns.db()}, {"coll", expCtx->ns.coll()}}},
+ {"fullDocument", Document{{"_id", 0}}}},
DocumentSource::GetNextResult::makePauseExecution(),
Document{{"documentKey", Document{{"_id", 1}}},
{"operationType", "update"_sd},
- {"fullDocument", BSONNULL},
{"ns", Document{{"db", expCtx->ns.db()}, {"coll", expCtx->ns.coll()}}}},
DocumentSource::GetNextResult::makePauseExecution()});
@@ -242,8 +241,8 @@ TEST_F(DocumentSourceLookupChangePostImageTest, ShouldPropagatePauses) {
next.releaseDocument(),
(Document{{"documentKey", Document{{"_id", 0}}},
{"operationType", "insert"_sd},
- {"fullDocument", Document{{"_id", 0}}},
- {"ns", Document{{"db", expCtx->ns.db()}, {"coll", expCtx->ns.coll()}}}}));
+ {"ns", Document{{"db", expCtx->ns.db()}, {"coll", expCtx->ns.coll()}}},
+ {"fullDocument", Document{{"_id", 0}}}}));
ASSERT_TRUE(lookupChangeStage->getNext().isPaused());
@@ -253,8 +252,8 @@ TEST_F(DocumentSourceLookupChangePostImageTest, ShouldPropagatePauses) {
next.releaseDocument(),
(Document{{"documentKey", Document{{"_id", 1}}},
{"operationType", "update"_sd},
- {"fullDocument", Document{{"_id", 1}}},
- {"ns", Document{{"db", expCtx->ns.db()}, {"coll", expCtx->ns.coll()}}}}));
+ {"ns", Document{{"db", expCtx->ns.db()}, {"coll", expCtx->ns.coll()}}},
+ {"fullDocument", Document{{"_id", 1}}}}));
ASSERT_TRUE(lookupChangeStage->getNext().isPaused());