Opinionated short-circuiting of specific query shapes

XMLWordPrintableJSON

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

      1. What would you like to communicate to the user about this feature?

      See the PR description: https://github.com/mongodb/mongoid/pull/6138

      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? See the PR description: https://github.com/mongodb/mongoid/pull/6138 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • 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:
            Jamis Buck
            Reporter:
            Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: