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

Where value in array inconsistent with ActiveRecord

    • Type: Icon: Task Task
    • Resolution: Done
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      Mongoid 4:

      Post.create(title: 'First title', body: 'First body', status: :published)
      # <Post _id: 522d0fe0d43dcdc08d000003, title: "First title", body: "First body", status: :published>
      Post.create(title: 'Second title', body: 'Second body', status: :unpublished)
      # <Post _id: 522d0fead43dcdc08d000004, title: "Second title", body: "Second body", status: :unpublished>
      Post.in(status: [:published, :unpublished]).count
      # 2
      Post.where(:status.in => [:published, :unpublished]).count
      # 2
      Post.where(:status => [:published, :unpublished]).count
      # 0
      

      ActiveRecord:
      http://edgeapi.rubyonrails.org/classes/ActiveRecord/QueryMethods.html#method-i-where

      User.where({ name: ["Alice", "Bob"]})
      # SELECT * FROM users WHERE name IN ('Alice', 'Bob')
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            jfine jfine
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: