我有以下 named_scope,它在 MySQL 和 sqlite 中运行良好,但在 Postgres 中运行良好:
course.rb
named_scope :current, :conditions => ['start < ? AND end > ? ', Time.now, Time.now], :order => 'start ASC'
然后我打电话:
Course.current
我得到错误:
PGError:错误:在“结束”第 1 行或附近出现语法错误:... WHERE (start < '2010-03-17 14:03:24.995746' AND end > '201... ^ : SELECT count(*) AS count_all 来自“课程”WHERE(开始 < '2010-03-17 14:03:24.995746' AND end > '2010-03-17 14:03:24.995748' )
我的 google-fu 让我失望了,所以我希望 Stack Overflow 不会。关于如何使该范围对 Postgres 友好的任何想法?谢谢,
德鲁