Why does AREL add OR IN (NULL) to BETWEEN terms?
The model has a scope:
scope :daily, lambda {|day| where :post_time =>
[day.beginning_of_day() .. day.end_of_day()] }
:post_time
declares non-nullable on the database, but AREL insists on adding false IN (NULL)
to the generated 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))
How can I stop it from doing this? Obviously I can add another condition not_eq(nil)
, :post_time != nil
or similar, but my question is why AREL does this, and how can I prevent it without additional conditions to negate it.
+3
source to share