
MySQL created_at time information missing
Reported by Sam Smoot | November 5th, 2007 @ 03:37 PM
A created_at property on a model means the model gets a before_create filter that automatically sets the current timestamp on a database record before it's saved. When the database backend is MySQL (tested on MySQL 5.x on OS X 10.4), the date value is set appropriately but the time is always 00:00:00.
The value in memory after the save is correct (includes time) and when Sqlite is used in place of MySQL, the value is correct. This would seem to indicate that it's something in the MySQL driver itself.
Comments and changes to this ticket
-
Yehuda Katz November 6th, 2007 @ 03:15 AM
This has to do with this:
def quote_time(value) "DATE('#{value.xmlschema}')" end def quote_datetime(value) "DATE('#{value}')" end def quote_date(value) "DATE('#{value.strftime("%Y-%m-%d")}')" end
As you can see, we're snipping out just the DATE for time and datetime, which is very incorrect. Unfortunately, modifying these breaks existing tests.
-
Yehuda Katz November 6th, 2007 @ 03:17 AM
- Assigned user set to Sam Smoot
-
Nick Plante November 7th, 2007 @ 08:58 AM
- State changed from new to open
- Milestone cleared.
-
Nick Plante November 7th, 2007 @ 03:08 PM
- Assigned user changed from Sam Smoot to Nick Plante
- State changed from open to resolved
Fixed, and existing tests pass. Using TIMESTAMP() for both datetime and time columns in MySQL.
-
Nick Plante November 7th, 2007 @ 03:15 PM
- State changed from resolved to open
needs to be applied. don't have commit rights :-)
-
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »