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

cannot create documents with non-unique id field

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • 12_01_17
    • Affects Version/s: 6.0.2
    • Component/s: None
    • Labels:
      None

      Issue is that I want to cache some documents that have an "id" field that is non-unique. If I store them using plain mongo it is fine because `_id` is auto-generated while `id` is irrelevant to the database.

      With `mondoid` though it hard aliases `id` to `_id` and there appears to be no way to avoid it. Looks like this is a change in 5.0.0.

      I think this breaks usage where developer does not have control over original document format. There should be an option to avoid alias `id` to `_id`.

      I tried `self.aliased_fields.clear` which stops doing the aliasing but document id is not auto-generated anymore so creating documents from JSON input breaks for all documents tryto have `null` value for `_id` and that breaks.

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            akostadinov Aleksandar Kostadinov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: