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

Scopes not chaining with Paranoia

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.0.4
    • Affects Version/s: None
    • Component/s: None
    • None

      It seems a bug.
      Lets look at sample model:

      class Item
        include Mongoid::Document
        include Mongoid::Paranoia
      
        field :owner_id, type: Integer, default: nil
        field :name, type: String
      
        scope :own, where(owner_id: nil)
      end
      

      The following queries are not same:
      1.

      Unable to find source-code formatter for language: item. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      .where(owner_id: nil).where(name: 'desk').count

      2.

      Unable to find source-code formatter for language: item. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      .own.where(name: 'desk').count

      First line produces log:

      Unable to find source-code formatter for language: command. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      ={:count=>:items, :query=>{"deleted_at"=>nil, "owner_id"=>nil, "name"=>"desk"}} (1.1594ms)

      But second line tells that scope is ignored:

      Unable to find source-code formatter for language: command. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      ={:count=>:items, :query=>{"deleted_at"=>nil, "term_name"=>"desk"}} (138.5915ms)

            Assignee:
            Unassigned Unassigned
            Reporter:
            happysoft Vadim Voitsiakh
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: