3
我在模型範圍:爲什麼AREL將ORIN(NULL)添加到BETWEEN條件中?
scope :daily, lambda {|day| where :post_time =>
[day.beginning_of_day() .. day.end_of_day()] }
:post_time
是在數據庫中聲明不爲空,但AREL堅持添加虛假IN (NULL)
到生成的SQL:
SELECT `<table>`.* FROM `<table>`
WHERE (`<table>`.`post_time`
BETWEEN '2013-02-05 00:00:00' AND '2013-02-05 23:59:59'
OR `<table>`.`post_time` IN (NULL))
我怎樣才能阻止它這樣做?很明顯,我可以再添加一個條件not_eq(nil)
,:post_time != nil
或類似的,但我的問題是爲什麼 AREL做到這一點,以及如何防止它沒有額外的條件否定它。
對我的尷尬,我必須認爲,直到現在我還以爲'[from..to]'**是[範圍]的語法(http://www.ruby-doc.org/core- 1.9.3/Range.html)... – 2013-02-12 13:24:34