Contract.all(:conditions => ['voided == ?', 0]).size
=> 364
Contract.all(:conditions => ['voided != ?', 0]).size
=> 8
Contract.all.size
=> 441
3个数字没有加起来(364 + 8!= 441)。编写:conditions
来计算voided
列值为NULL或等于零的行的正确方法是什么?
答案 0 :(得分:1)
Contract.all(:conditions => {:voided => nil})
或
Contract.all(:conditions => ['voided IS NULL'])
答案 1 :(得分:0)
Contract.all(:conditions => ["voided is ?", nil]).size
Contract.all(:conditions => ["voided is not ?", nil]).size