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

Criteria merging broken in latest patches

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Blocker - P1 Blocker - P1
    • 6.0.2, origin-2.2.2
    • Affects Version/s: 6.0.1
    • Component/s: None
    • None

      After bumping to latest patch, I'm getting this error from some of my tests:

      Failure/Error:
      Pricing::Discount
      .where(:created_at.lt => 30.days.ago)
      .active # scope defined as ->

      { where(active: true) }

      .pluck(:id)
      .map(&:to_s)

      NoMethodError:
      undefined method `|' for 2016-09-19 13:22:25 UTC:Time

      1. /Users/bcrouse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/mongoid-6.0.1/lib/mongoid/criteria/queryable/selector.rb:24:in `block (2 levels) in merge!'
      2. /Users/bcrouse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/mongoid-6.0.1/lib/mongoid/criteria/queryable/selector.rb:23:in `merge'
      3. /Users/bcrouse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/mongoid-6.0.1/lib/mongoid/criteria/queryable/selector.rb:23:in `block in merge!'
      4. /Users/bcrouse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/mongoid-6.0.1/lib/mongoid/criteria/queryable/selector.rb:21:in `each_pair'
      5. /Users/bcrouse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/mongoid-6.0.1/lib/mongoid/criteria/queryable/selector.rb:21:in `merge!'
      6. /Users/bcrouse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/mongoid-6.0.1/lib/mongoid/criteria.rb:240:in `merge!'
      7. /Users/bcrouse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/mongoid-6.0.1/lib/mongoid/criteria.rb:224:in `merge'
      8. /Users/bcrouse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/mongoid-6.0.1/lib/mongoid/scopable.rb:322:in `block (2 levels) in define_scope_method'
      9. /Users/bcrouse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/mongoid-6.0.1/lib/mongoid/criteria.rb:500:in `block in method_missing'
      10. /Users/bcrouse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/mongoid-6.0.1/lib/mongoid/scopable.rb:230:in `with_scope'
      11. /Users/bcrouse/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/mongoid-6.0.1/lib/mongoid/criteria.rb:499:in `method_missing'

      It looks like it was introduced with this commit: https://github.com/mongodb/mongoid/commit/7bef4aaad6a0a1cbbb21c6618707e8251be949ba which was a patch for MONGOID-4310

            Assignee:
            Unassigned Unassigned
            Reporter:
            bcrouse Ben Crouse
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: