Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-5140

Atomic #unset method should allow Hash args (in addition to current String/Symbol/Array)

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 7.1.11, 7.2.6, 7.3.3
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible

      PR raised here: https://github.com/mongodb/mongoid/pull/5034

       

      The native MongoDB interface for $unset uses a Hash object rather than an array. Therefore, for consistency, Mongoid should allow a Hash to be the argument to `.unset`.

      { $unset: { <field1>: "", ... } }
      
      

      According to [MongoDB's docs](https://docs.mongodb.com/manual/reference/operator/update/unset/):

      > The specified value in the $unset expression (i.e. "") does not impact the operation.

      So we should simply take the Hash's keys, even if the value is nil or false.

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            shields@tablecheck.com Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: