Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/extjson/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ pub(crate) struct DateTime {
pub(crate) enum DateTimeBody {
Canonical(Int64),
Relaxed(String),
Legacy(i64),
}

impl DateTimeBody {
Expand All @@ -282,6 +283,7 @@ impl DateTime {
})?;
Ok(datetime)
}
DateTimeBody::Legacy(ms) => Ok(crate::DateTime::from_millis(ms)),
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/tests/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,19 @@ fn test_de_uuid_extjson_string() {
assert_eq!(actual_uuid_bson, expected_uuid_bson);
}

#[test]
fn test_de_date_extjson_number() {
let _guard = LOCK.run_concurrently();

let ext_json_canonical = r#"{ "$date": { "$numberLong": "1136239445000" } }"#;
let expected_date_bson: Bson = serde_json::from_str(ext_json_canonical).unwrap();

let ext_json_legacy_java = r#"{ "$date": 1136239445000 }"#;
let actual_date_bson: Bson = serde_json::from_str(ext_json_legacy_java).unwrap();

assert_eq!(actual_date_bson, expected_date_bson);
}

#[test]
fn test_de_oid_string() {
let _guard = LOCK.run_concurrently();
Expand Down