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

Retrieving same document twice messes up the criteria

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

      class Doc
      embeds_many :foo

      class Foo
      mydate type: DateTime

      This raises error

      my_doc = Doc.find(id)
      my_doc = Doc.where(:"foo.mydate".gte => now).find(id)

      undefined method `>=' for [2013-08-03 23:00:00 UTC, 2013-08-03 00:00:00 UTC]:Array
      mongoid (2.4.12) lib/mongoid/matchers/default.rb:66:in `determine'

      This works

      my_doc = Doc.where(:"foo.mydate".gte => now).find(id)

      So if I've used a find before the criteria doesn't work but removing the first find solkves the issue. I need though to be able to run the same query twice.

            Assignee:
            Unassigned Unassigned
            Reporter:
            hankthetank hankthetank
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: