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

Criteria for a field clobbered instead of combined when using symbol operators

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 7.1.1, 7.0.7
    • Fix Version/s: 7.1.2
    • Component/s: Query
    • Labels:
      None
    • Environment:
      tested on ruby 2.6.6

      Description

      When querying using or(), '$or', or even other nested queries like '$and', mongoid is improperly clobbering multiple criteria for the same field.

      For example, `where(:left.gte => 8, :left.lte => 12)` results in the criteria `{"left"=>{"$gte"=>8, "$lte"=>12}}`.

      In contast, using the same as part of or(), `or({:left.gte => 8, :left.lte => 12})` results in the criteria `{"$or"=>[{"left"=>{"$lte"=>12}}]}` which is missing the `:left >= 8` condition entirely.

      Directly specifying '$or' inside of where() exhibits the same problem, as does even using '$and', suggesting that it's farther reaching than merely 'or'.

      An example to reproduce the issue is attached.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              oleg.pudeyev Oleg Pudeyev
              Reporter:
              tmorgan thomas morgan
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: