summaryrefslogtreecommitdiff
path: root/src/mongo/bson/util
diff options
context:
space:
mode:
authormatt dannenberg <matt.dannenberg@10gen.com>2015-09-16 08:23:33 -0400
committermatt dannenberg <matt.dannenberg@10gen.com>2015-09-17 05:25:25 -0400
commitb7ac467dbe15275ffcd51f446f9b42491f29e922 (patch)
treeb39273bb2e55c9f20c60adf2837b6bad5ce33ecf /src/mongo/bson/util
parentaa190f0e2b34d29231b2ddd6660e641821071c1f (diff)
downloadmongo-b7ac467dbe15275ffcd51f446f9b42491f29e922.tar.gz
SERVER-19905 consistently use t as the field name for the term portion of an OpTime
Diffstat (limited to 'src/mongo/bson/util')
-rw-r--r--src/mongo/bson/util/bson_extract.cpp11
-rw-r--r--src/mongo/bson/util/bson_extract_test.cpp8
2 files changed, 6 insertions, 13 deletions
diff --git a/src/mongo/bson/util/bson_extract.cpp b/src/mongo/bson/util/bson_extract.cpp
index 4906d0897a5..54d1e1f47ae 100644
--- a/src/mongo/bson/util/bson_extract.cpp
+++ b/src/mongo/bson/util/bson_extract.cpp
@@ -32,13 +32,6 @@
namespace mongo {
-namespace {
-
-const char kTermFieldName[] = "term";
-const char kTimestampFieldName[] = "ts";
-
-} // namespace
-
Status bsonExtractField(const BSONObj& object, StringData fieldName, BSONElement* outElement) {
BSONElement element = object.getField(fieldName);
if (element.eoo())
@@ -113,11 +106,11 @@ Status bsonExtractOpTimeField(const BSONObj& object, StringData fieldName, repl:
BSONObj opTimeObj = element.Obj();
Timestamp ts;
- status = bsonExtractTimestampField(opTimeObj, kTimestampFieldName, &ts);
+ status = bsonExtractTimestampField(opTimeObj, repl::OpTime::kTimestampFieldName, &ts);
if (!status.isOK())
return status;
long long term;
- status = bsonExtractIntegerField(opTimeObj, kTermFieldName, &term);
+ status = bsonExtractIntegerField(opTimeObj, repl::OpTime::kTermFieldName, &term);
if (!status.isOK())
return status;
*out = repl::OpTime(ts, term);
diff --git a/src/mongo/bson/util/bson_extract_test.cpp b/src/mongo/bson/util/bson_extract_test.cpp
index 1c7261d1301..95951efb87e 100644
--- a/src/mongo/bson/util/bson_extract_test.cpp
+++ b/src/mongo/bson/util/bson_extract_test.cpp
@@ -86,7 +86,7 @@ TEST(ExtractBSON, ExtractStringFieldWithDefault) {
TEST(ExtractBSON, ExtractOpTimeField) {
// Outer object cases.
- BSONObj obj = BSON("a" << BSON("ts" << Timestamp(10, 0) << "term" << 2) << "b"
+ BSONObj obj = BSON("a" << BSON("ts" << Timestamp(10, 0) << "t" << 2) << "b"
<< "notAnObj");
repl::OpTime opTime;
ASSERT_OK(bsonExtractOpTimeField(obj, "a", &opTime));
@@ -97,13 +97,13 @@ TEST(ExtractBSON, ExtractOpTimeField) {
// Missing timestamp field.
obj = BSON("a" << BSON("ts"
<< "notATimestamp"
- << "term" << 2));
+ << "t" << 2));
ASSERT_EQUALS(ErrorCodes::TypeMismatch, bsonExtractOpTimeField(obj, "a", &opTime));
// Wrong typed timestamp field.
- obj = BSON("a" << BSON("term" << 2));
+ obj = BSON("a" << BSON("t" << 2));
ASSERT_EQUALS(ErrorCodes::NoSuchKey, bsonExtractOpTimeField(obj, "a", &opTime));
// Missing term field.
- obj = BSON("a" << BSON("ts" << Timestamp(10, 0) << "term"
+ obj = BSON("a" << BSON("ts" << Timestamp(10, 0) << "t"
<< "notANumber"));
ASSERT_EQUALS(ErrorCodes::TypeMismatch, bsonExtractOpTimeField(obj, "a", &opTime));
// Wrong typed term field.