-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
Hi !
It seems that I have the same problem as MONGOID-1916 and MONGOID-2025 but on mongoid 3.0.6 and the provided workaround (define {{default_scope}}last) doesn't work :
scope :unused, where(:count.lte => 0) default_scope where(:count.gt => 0)
`
This is fine :
Unable to find source-code formatter for language: `. 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
1.9.3-p194 :001 > Credential::Section.all => #<Mongoid::Criteria selector: {"count"=>{"$gt"=>0}}, options: {}, class: Credential::Section, embedded: false>
`
This is not (as both scopes are exact opposites, it returns nothing) :
Unable to find source-code formatter for language: `. 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
1.9.3-p194 :002 > Credential::Section.unused => #<Mongoid::Criteria selector: {"count"=>{"$gt"=>0, "$lte"=>0}}, options: {}, class: Credential::Section, embedded: false>
`
I've even tried with scope :unused, unscoped.where(:count.lte => 0) with the same result.
Only this is working :
Unable to find source-code formatter for language: `. 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
1.9.3-p194 :003 > Credential::Section.unscoped.unused => #<Mongoid::Criteria selector: {"count"=>{"$lte"=>0}}, options: {}, class: Credential::Section, embedded: false>
`
Is this a bug or have I done something wrong ?