Opinionated short-circuiting of specific query shapes

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Unresolved
    • Priority: Major - P3
    • 9.1.0
    • Affects Version/s: None
    • Component/s: Query
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Rails 6.1 introduced the following behavior in ActiveRecord:

      Avoid making query when using `where(attr: [])`
      https://github.com/rails/rails/pull/37266

      Mongoid should implement something similar. For example, the following queries are guaranteed never to return any results:

      Users.any_in(name: [])
      Users.where(name: 'Bob').where(name: 'Joe')

      Such code should return a Mongoid::Criteria but calling .to_a on that criteria returns [] without generating a DB query.

            Assignee:
            Unassigned
            Reporter:
            Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: