Option to unset nil-valued fields in DB

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Attributes
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      In MongoDB there is a distinction between "unset" and "null".

      • "null" is a value, e.g. Customer.set(name: nil)
      • "unset" is the absence of any value, e.g. the empty set Customer.unset(:name)

      Null causes all sorts of problems especially with indexes, for example it is not ignored in sparse indexes; the key remains in the document.

      Unfortunately in Ruby, the demongoization causes both the null and unset cases to be represented as "nil", so it is impossible from the value alone to determine the actual state of the DB.

      It would be really nice if it were possible to have a config mode in Mongoid such that the value null (nil in Ruby) unsets the value from the DB itself, it would create much more consistent/intuitive behavior.

              Assignee:
              Unassigned
              Reporter:
              Johnny Shields
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated: