Uploaded image for project: 'Swift Driver'
  1. Swift Driver
  2. SWIFT-281

Allow .uuidDecodingStrategy and .dateDecodingStrategy to be set for BSONDecoder

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.0.8
    • Component/s: None
    • Labels:

      Description

      As proposed by Matt Broadstone:

      Similarly to JSONDecoder's dateDecodingStrategy, we should allow a user to choose how both Dates and UUIDs gets decoded.

      The Date strategy should be pretty much identical to the JSONDecoder behavior there, though we may want to default to our current date decoding strategy instead of deferring to Date like JSONDecoder does by default.

      We should provide an analogous option for UUIDs, so that we can support decoding them in the reverse manner of how this PR encodes them in UUID.encode(to storage....)

      We already special case ambiguous errors involving Date decoding, and we should do the same for UUID too.

      These options should be added via open properties on BSONDecoder that users can set, i.e. with something like:

      let decoder = BSONDecoder()
      decoder.dateDecodingStrategy = .deferredToDate 

      Therefore this will require implementing SWIFT-260.

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              patrick.freed Patrick Freed
              Reporter:
              kaitlin.mahar Kaitlin Mahar
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: