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

Single-value .in should convert to .where (resolve deprecated .in scalar value behavior)

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Minor - P4 Minor - P4
    • 8.1.0, 9.0.0, 8.0.4
    • Affects Version/s: None
    • Component/s: Docs

      From the docs (tested behavior --> correct as of Mongoid 7.5):

      .in has historically wrapped non-``Array`` values in arrays,
      as the following example demonstrates:
      
      Band.in(year: 1950)
      #=> #<Mongoid::Criteria selector: \{"year"=>{"$in"=>[1950]}}
      
      This wrapping behavior is deprecated and should not be relied on. It may be
      removed in a future release of Mongoid.
      

      It would be good to resolve the deprecation and move forward here. My preference to do so would be to have Band.in(year: 1950) behave the same as Band.where(year: 1950):

      Band.in(year: 1950)
      #=> #<Mongoid::Criteria selector: \{"year"=>1950}}
      

      Other ideas are also acceptable; key requirement is not to have dangling "Mongoid supports this but please don't use it" lines in the documentation.

            Assignee:
            alex.bevilacqua@mongodb.com Alex Bevilacqua
            Reporter:
            shields@tablecheck.com Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: