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

Mongoid should not permit using the field name "collection_name"

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 6.1.1
    • Affects Version/s: None
    • Component/s: None
    • None

      I recently dealt with an issue that took about 12 hours of debugging and came down to using a field name that isn't allowed. Throughout the debugging process, Mongoid gave no indication that I had used an un-permitted field name.

      Here is a SO post detailing debugging the issue: http://stackoverflow.com/questions/42423511/updating-a-rails-models-attributes-through-mongoid-using-normal-persistence-met

      The actual issue is caused by me using the field name "collection_name". While choosing the field name, I recognized that "collection" might pose issues but thought adding "_name" would avoid it somehow. It is caused by a clash with this method's name: https://github.com/mongodb/mongoid/blob/master/lib/mongoid/persistence_context.rb#L82

      I believe that Mongoid should somehow warn the user of this. I don't see a properly documented list of disallowed field names either.

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            skreem N J
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: