summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Wahlin <james.wahlin@mongodb.com>2019-10-03 17:01:45 +0000
committerevergreen <evergreen@mongodb.com>2019-10-03 17:01:45 +0000
commitc1cefc2d974832bb62d73bea3498ec417c332e7b (patch)
tree750f6e4fec6df6680ff66dfb48d9b923d86a1bbb
parent532c0a9b072d01bfc740768592ed6c352459bc85 (diff)
downloadmongo-c1cefc2d974832bb62d73bea3498ec417c332e7b.tar.gz
SERVER-42007 Deprecate $currentDate update modifier
-rw-r--r--src/mongo/db/update/current_date_node.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/db/update/current_date_node.cpp b/src/mongo/db/update/current_date_node.cpp
index 9df15695850..4933c8adcf9 100644
--- a/src/mongo/db/update/current_date_node.cpp
+++ b/src/mongo/db/update/current_date_node.cpp
@@ -27,6 +27,8 @@
* it in the license file.
*/
+#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kWrite
+
#include "mongo/platform/basic.h"
#include "mongo/db/update/current_date_node.h"
@@ -34,6 +36,8 @@
#include "mongo/db/logical_clock.h"
#include "mongo/db/logical_time.h"
#include "mongo/db/service_context.h"
+#include "mongo/util/debug_util.h"
+#include "mongo/util/log.h"
namespace mongo {
@@ -42,6 +46,8 @@ constexpr StringData kType = "$type"_sd;
constexpr StringData kDate = "date"_sd;
constexpr StringData kTimestamp = "timestamp"_sd;
+Rarely currentDateDeprecationSampler; // Used to occasionally log deprecation messages.
+
void setValue(mutablebson::Element* element, bool typeIsDate) {
if (typeIsDate) {
invariant(element->setValueDate(mongo::jsTime()));
@@ -56,6 +62,12 @@ Status CurrentDateNode::init(BSONElement modExpr,
const boost::intrusive_ptr<ExpressionContext>& expCtx) {
invariant(modExpr.ok());
+ if (currentDateDeprecationSampler.tick()) {
+ warning() << "The $currentDate update operator is deprecated. As an alternative perform "
+ "updates with an aggregation pipeline and either the 'NOW' or 'CLUSTER_TIME' "
+ "system variables.";
+ }
+
if (modExpr.type() == BSONType::Bool) {
_typeIsDate = true;
} else if (modExpr.type() == BSONType::Object) {