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

lambda's in default_scope not executing properly

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

      Hi,

      Running Mongoid 3.1.4 on Rails 3.2.13.

      We have a default scope like this:
      default_scope lambda

      { where(:published_at.lte => DateTime.now) }

      This seems to work fine in console, but on a web request, it's using an old date/time.

      It's 07:39 UTC now, but if you look at this server output, you can see it's still querying library_items for 07:31.

      You can also see though that mosaics and themes, which have the same thing in a named scope rather than a default scope work fine and are showing 07:39:

      MOPED: 127.0.0.1:27017 QUERY        database=audacious_development collection=themes selector={"$query"=>{"published_at"=>{"$lte"=>2013-06-23 07:39:12 UTC}, "published"=>true}, "$orderby"=>{"published_at"=>-1, "created_at"=>-1}} flags=[:slave_ok] limit=-1 skip=0 batch_size=nil fields=nil (0.8950ms)
      MOPED: 127.0.0.1:27017 QUERY        database=audacious_development collection=mosaics selector={"$query"=>{"published_at"=>{"$lte"=>2013-06-23 07:39:12 UTC}}, "$orderby"=>{"published_at"=>-1}} flags=[:slave_ok] limit=-1 skip=0 batch_size=nil fields=nil (0.6385ms)
      MOPED: 127.0.0.1:27017 COMMAND      database=audacious_development command={:count=>"library_items", :query=>{"published_at"=>{"$lte"=>2013-06-23 07:31:29 UTC}, "_type"=>"LibraryLink"}} (1.9977ms)
      MOPED: 127.0.0.1:27017 QUERY        database=audacious_development collection=library_items selector={"$query"=>{"published_at"=>{"$lte"=>2013-06-23 07:31:29 UTC}, "_type"=>"LibraryLink"}, "$orderby"=>{"published_at"=>-1, "created_at"=>-1}} flags=[:slave_ok] limit=3 skip=0 batch_size=nil fields=nil (2.1386ms)
      

      Thanks,

      Ian

            Assignee:
            durran Durran Jordan
            Reporter:
            ichilton ichilton
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: