Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1024

Provide a way to allow alternate field names to ease schema migration

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: 1.9.2
    • Fix Version/s: None
    • Component/s: Bson
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible

      Description

      It's currently a total pain when we want to make a schema migration (shortening a field name for example). We need to mark the old property with {{ [BsonIgnoreIfNull] }} (or {{ ...IfDefault] }} and that properties set the new property we'd like to use instead and make the old property always return null (or default). Not clean at all and difficult to read.

      To my opinion a much cleaner way would be to have a custom attribute like:
      {{ [BsonAllowedAlternateNames("name1",123,etc.)] }} that would allow that property to be set by those element names, only affecting deserialization of the documents (bson => c#) and not serialization.

      I realize it could lead to deserialization conflicts: those conflicts could be managed by attribute settings (like "takes precedence" or so), and/or by a custom resolve method.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              tubededentifrice Vincent
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: