diff options
author | Shaun Verch <shaun.verch@10gen.com> | 2012-11-27 15:48:36 -0800 |
---|---|---|
committer | Shaun Verch <shaun.verch@10gen.com> | 2012-12-18 17:00:24 -0500 |
commit | 67ec3ed7d7550cf5d39458c5a6026568a802557a (patch) | |
tree | 297b063531ba4c9a0ae0357aee1fe45d6bde33dd /src/mongo | |
parent | 9c1a0b66fd7256d8b99bf0171bdad09fc05f7b40 (diff) | |
download | mongo-67ec3ed7d7550cf5d39458c5a6026568a802557a.tar.gz |
SERVER-7437 Fixed handling of timestamp object in jsonString
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/jsobj.cpp | 7 | ||||
-rw-r--r-- | src/mongo/dbtests/jsontests.cpp | 6 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/mongo/db/jsobj.cpp b/src/mongo/db/jsobj.cpp index eb3fa3be785..99d45b772fb 100644 --- a/src/mongo/db/jsobj.cpp +++ b/src/mongo/db/jsobj.cpp @@ -243,7 +243,12 @@ namespace mongo { break; case Timestamp: - s << "{ \"t\" : " << timestampTime() << " , \"i\" : " << timestampInc() << " }"; + if ( format == TenGen ) { + s << "Timestamp( " << ( timestampTime() / 1000 ) << ", " << timestampInc() << " )"; + } + else { + s << "{ \"$timestamp\" : { \"t\" : " << ( timestampTime() / 1000 ) << ", \"i\" : " << timestampInc() << " } }"; + } break; case MinKey: diff --git a/src/mongo/dbtests/jsontests.cpp b/src/mongo/dbtests/jsontests.cpp index 82e6963767d..a05c8d1a7df 100644 --- a/src/mongo/dbtests/jsontests.cpp +++ b/src/mongo/dbtests/jsontests.cpp @@ -357,7 +357,11 @@ namespace JsonTests { BSONObjBuilder b; b.appendTimestamp( "x" , 4000 , 10 ); BSONObj o = b.obj(); - ASSERT_EQUALS( "{ \"x\" : { \"t\" : 4000 , \"i\" : 10 } }" , o.jsonString() ); + ASSERT_EQUALS( "{ \"x\" : { \"$timestamp\" : { \"t\" : 4, \"i\" : 10 } } }", + o.jsonString( Strict ) ); + ASSERT_EQUALS( "{ \"x\" : { \"$timestamp\" : { \"t\" : 4, \"i\" : 10 } } }", + o.jsonString( JS ) ); + ASSERT_EQUALS( "{ \"x\" : Timestamp( 4, 10 ) }", o.jsonString( TenGen ) ); } }; |