Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-2643

Allow Field Name Duplication with Modifiers

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Do
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Write Ops
    • Labels:
      None

      Description

      Currently, if a field is referenced twice within two different modifiers, Mongo errors out, even if their is actually conflict. In other words, the error check is dumb. It's understandable why this was done, but I think this behavior deserves further consideration as Mongo matures. Take the following example:

      {$set :

      {age: 20}

      , $inc : {age: 2}}

      Running this as part of an update will generate a "Field name duplication not allowed with modifiers" error. Any human reading this however can easily determine the intention, and that such an operation could have succeeded without error. The result of which should have been setting the field "age" to the value 22.

      A relatively easy first step solution here, would be to allow name duplication between the $set modifiers and the other modifiers. The rule should be that the $set modifier operation should always happen first, followed by the rest of the modifiers, in order. In other words, any other modifier operations should be applied to the result of $set.

      Of course I'm unaware of how easy or difficult this would be to implement in Mongo, given it's atomic nature and all, but it's worth considering whether implementing this is possible or not.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-server-query Backlog - Query Team (Inactive)
              Reporter:
              wardrop Tom Wardrop
              Participants:
              Votes:
              24 Vote for this issue
              Watchers:
              25 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: