-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Minor - P4
-
Affects Version/s: None
-
Component/s: None
spokodev has created [PR #909: fix: use the first instant of year 10000 as the relaxed
EJSON date bound|https://github.com/mongodb/js-bson/pull/909] in js-bson
Actual vs Expected behavior
EJSON.stringify({ a: new Date(253402300800000) }, { relaxed: true })
// {"a":{"$date":"+010000-01-01T00:00:00Z"}} invalid 6-digit-year ISO
// should be {"a":{"$date":{"$numberLong":"253402300800000"}}}
Use Case
As a user of js-bson
I want EJSON serialization to choose the correct type for value serialization when using dates
So that the server does not reject bson dates sourced from deserialized ejson.
User Experience
- Today: If a user serializes a document to ejson, dates which breach the 10k year threshold (bson-corpus spec) by up to 5 hours should be encoded as a number. Today, they are encoded as a date. Theoretically, if these are somehow serialized into bson, they will fail to be passed to the server as these dates are not supported:
Not all database operations and drivers support the full 64-bit range. You may safely work with dates with years within the inclusive range 0 through 9999.
Expected Behaviour: the 'inRange' type switching behaviour should be tightened to align with the bson-corpus spec, disallowing dates >9999 years.
Dependencies
- N/A
Risks/Unknowns
- Potentially a breaking change. If users routinely send large integers through here as a date that satisfy the narrow range (10k+years + 5hrs), they will see a change in behaviour
Acceptance Criteria
Implementation Requirements
- Ensure the boundary date value returns a valid date encoding in EJSON.stringify
Testing Requirements
- Regression test for the bound
Documentation Requirements
- Release note crediting the user
Follow Up Requirements
- N/A
- is duplicated by
-
NODE-7651 use the first instant of year 10000 as the relaxed EJSON date bound
-
- Closed
-