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

field named empty causes find issues

    • Type: Icon: Task Task
    • Resolution: Done
    • 2.0.2
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      Reproduction:
      1) Create a document with a boolean field named :empty. Set field to true.
      2) Enable raise_not_found_error
      3) Try to locate this document using Model.find (fails).
      4) Disable raise_not_found_error
      4) Try to locate document using Model.find (document magically reappears from the dead!).

      Cause:
      mongoid/contexts/ids.rb raises DocumentNotFound if raise_not_found_error and result.blank? are true. If the object responds to "empty" with "true," blank? also returns true, resulting in a DocumentNotFound error even though the document exists. With raise_not_found_error disabled, this faulty blank? logic is never triggered.

            Assignee:
            durran Durran Jordan
            Reporter:
            bri3d Brian Ledbetter
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: