This project is archived and is in readonly mode.

#6581 ✓invalid
Jan Bernacki

Date column bug

Reported by Jan Bernacki | March 15th, 2011 @ 09:23 AM


create_table :downloads do |t| :downloaded_at
  t.integer :count, :default => 0

Download.create(:downloaded_at =>
d = Download.first # => #<Download id: 1, downloaded_at: "2011-03-15", count: 0>
Download.where(:downloaded_at => d.downloaded_at) # => []

Database Mysql, SQLite, rails 3.0.5

if I use Download.create(:downloaded_at => Date.current), I find it after.

Maybe it's not a Bug, but intuitively, it seems that is correct.

Comments and changes to this ticket

  • Josh Kalderimis

    Josh Kalderimis March 15th, 2011 @ 12:53 PM

    • State changed from “new” to “invalid”
    • Importance changed from “” to “Low”

    Hi Releu,

    The difference between and Date.current is that has a higher precision.

    When you create a Download using it is cast to a Date, thus losing its precision. But when you query for a Download using that precision is not cast but instead just passed to your DB. You can check this for yourself by looking at the logs.

    I will close this issue as it is not a bug.



  • Jan Bernacki

    Jan Bernacki March 15th, 2011 @ 01:07 PM

    Hello Josh,

    Thanks for the explanation.


Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>