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

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

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.9.2
    • Component/s: BSON
    • Labels:
      None
    • Fully Compatible

      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.

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

              Created:
              Updated: