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

Allow .uuidDecodingStrategy and .dateDecodingStrategy to be set for BSONDecoder

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 0.0.8
    • None

    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

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

              Dates

                Created:
                Updated:
                Resolved: