2012-12-08 111 views
0

有人能解釋爲什麼下面的查詢:查詢使用>(大於)返回記錄> =(大於或等於)

> modified_after = DateTime.parse "2012-12-06T17:40:36+00:00" 
> Contact.unscoped.where("updated_at > :time OR deleted_at > :time", {:time => modified_after}) 

也返回記錄與updated_at等於modified_after

Contact Load (0.4ms) SELECT "contacts".* FROM "contacts" WHERE (updated_at > '2012-12-06 17:40:36' OR deleted_at > '2012-12-06 17:40:36') => [ 
#<Contact id: 28, first_name: "John", last_name: "A", deleted_at: nil, created_at: "2012-12-06 17:40:36", updated_at: "2012-12-06 17:40:36", email: nil, notes: nil>, 
#<Contact id: 29, first_name: "Mark", last_name: "B", deleted_at: nil, created_at: "2012-12-06 17:40:36", updated_at: "2012-12-06 17:40:36", email: nil, notes: nil>, 
#<Contact id: 30, first_name: "Michael", last_name: "C", deleted_at: nil, created_at: "2012-12-06 17:40:36", updated_at: "2012-12-06 17:40:36", email: nil, notes: nil> 
] 

回答

2

這可能是那些時間比查詢時間多毫秒。你正在運行什麼版本的Rails?看看這個bug,看看它是否相關:https://github.com/rails/rails/issues/7385

+1

已導軌3.2.8。升級到3.2.9,一切按預期工作。謝謝! –

相關問題