Allow $merge on field to have explicitly specified _id + shard key

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Execution
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Currently on a sharded collection on field of $merge if not present, defaults to _id + shard key: 

      https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/#std-label-merge-on

      However, if we explicitly state _id + shard key on a collection that doesn't have _id as a part of it's shard key, $merge validation will fail, because it won't find an index that is unique and matches all on fields.

      It would be nice to make the default value of "on" behave consistently if it is explicit or not.

       

      Small repro script attached: repro.js

      Note that in EXPLAIN DEFAULT "on" field is serialized to .[_id, shardKey]

        1. repro.js
          1 kB
          Ivan Fefer

            Assignee:
            Unassigned
            Reporter:
            Ivan Fefer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: