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: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.9.2
    • Component/s: BSON
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      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:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: