Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-3504

Add unambiguous Timestamp() constructor overload

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Critical - P2 Critical - P2
    • bson-4.5.0
    • Affects Version/s: None
    • Component/s: BSON
    • Not Needed

      Quoting myself from Slack:

      So … as we just discovered in #mongosh, the legacy shell and the driver have the exact opposite ordering of arguments:
      https://mongodb.slack.com/archives/CUHC9R8J0/p1627483982391900?thread_ts=1627440319.366000&cid=CUHC9R8J0

      This is obviously not good – we want to have BSON class definitions in mongosh that are usable in the driver as well, but this kind of undetectable incompatibility with the legacy shell is probably not really acceptable.

      I’m thinking that we’d probably rather get this resolved as soon as we can, given that we’re already post-GA. The best way to do that is probably to introduce a new format that the legacy shell does not understand, therefore removing ambiguity. Based on past feedback like on the Long and Decimal128 cases, I think it’s safe to say that people care about terseness a lot, so while we could use Timestamp.fromBits(i, t)  here, my gut feeling would be that it makes sense to add a new constructor format, say, Timestamp({ t: 1627479034, i: 1 }) . If we agree that this is okay, we could implement it in mongosh and then add support to the driver BSON class at the same time (but we wouldn’t have to wait for a release).

      As durran pointed out, the order of the arguments should also be reversed in the Node.js BSON library, but since this is a breaking change, that is probably not a viable short-term solution here.

            Assignee:
            anna.henningsen@mongodb.com Anna Henningsen
            Reporter:
            anna.henningsen@mongodb.com Anna Henningsen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: