Skip to content

Commit

Permalink
Use time in seconds for BsonTimeStamp field when converting to record
Browse files Browse the repository at this point in the history
  • Loading branch information
dinujoh committed May 10, 2024
1 parent 34f1702 commit 5328827
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public class BsonHelper {
writer.writeString(REGEX_OPTIONS, value.getOptions());
writer.writeEndObject();
})
.timestampConverter((value, writer) -> writer.writeNumber(String.valueOf(value.getValue())))
.timestampConverter((value, writer) -> writer.writeNumber(String.valueOf(value.getTime())))
.undefinedConverter((value, writer) -> writer.writeNull())
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ private static Stream<Arguments> mongoDataTypeProvider() {
"{\"_id\": \"6634ed693ac62386d57bcaf0\", \"objectIdField\": \"6634ed693ac62386d57b12d0\"}"),
Arguments.of(
"{\"_id\": { \"$oid\": \"6634ed693ac62386d57bcaf0\" }, \"timestampField\": { \"$timestamp\": {\"t\": 1714744681, \"i\": 29}}}",
"{\"_id\": \"6634ed693ac62386d57bcaf0\", \"timestampField\": 7364772325884952605}"),
"{\"_id\": \"6634ed693ac62386d57bcaf0\", \"timestampField\": 1714744681}"),
Arguments.of(
"{\"_id\": { \"$oid\": \"6634ed693ac62386d57bcaf0\" }, \"regexField\": { \"$regularExpression\": {\"pattern\": \"^ABC\", \"options\": \"i\"}}}",
"{\"_id\": \"6634ed693ac62386d57bcaf0\", \"regexField\": {\"pattern\": \"^ABC\", \"options\": \"i\"}}"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,9 +505,9 @@ private static Stream<Arguments> mongoDataTypeProvider() {
new BsonTimestamp(Math.abs(random.nextLong())),
"{\"_id\": \"6634ed693ac62386d57bcaf0\", \"doubleValue\": 3.14159}"),
Arguments.of(
"{\"_id\": { \"$oid\": \"6634ed693ac62386d57bcaf0\" }, \"longValue\": { \"$numberLong\": \"1234567890123456768\"}}",
"{\"_id\": { \"$oid\": \"6634ed693ac62386d57bcaf0\" }, \"longValue\": { \"$numberLong\": \"9223372036854775801\"}}",
new BsonObjectId(new ObjectId()),
"{\"_id\": \"6634ed693ac62386d57bcaf0\", \"longValue\": 1234567890123456768}"),
"{\"_id\": \"6634ed693ac62386d57bcaf0\", \"longValue\": 9223372036854775801}"),
Arguments.of(
"{\"_id\": { \"$oid\": \"6634ed693ac62386d57bcaf0\" }, \"stringField\": \"Hello, Mongo!\"}",
new BsonDocument(),
Expand Down Expand Up @@ -539,7 +539,7 @@ private static Stream<Arguments> mongoDataTypeProvider() {
Arguments.of(
"{\"_id\": { \"$oid\": \"6634ed693ac62386d57bcaf0\" }, \"timestampField\": { \"$timestamp\": {\"t\": 1714744681, \"i\": 29}}}",
new BsonObjectId(new ObjectId()),
"{\"_id\": \"6634ed693ac62386d57bcaf0\", \"timestampField\": 7364772325884952605}"),
"{\"_id\": \"6634ed693ac62386d57bcaf0\", \"timestampField\": 1714744681}"),
Arguments.of(
"{\"_id\": { \"$oid\": \"6634ed693ac62386d57bcaf0\" }, \"regexField\": { \"$regularExpression\": {\"pattern\": \"^ABC\", \"options\": \"i\"}}}",
new BsonObjectId(new ObjectId()),
Expand Down

0 comments on commit 5328827

Please sign in to comment.