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

Retrieving same document twice messes up the criteria

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 3.1.0
    • Component/s: None

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: