[JIRA] Commented: (ACTIVERECORD_JDBC-18) Time is not saved with the default timezone (mssql)
- From: "mdub (JIRA)" <jira-no-reply@kenai.com>
- To: issues@activerecord-jdbc.kenai.com
- Subject: [JIRA] Commented: (ACTIVERECORD_JDBC-18) Time is not saved with the default timezone (mssql)
- Date: Wed, 17 Mar 2010 06:22:16 +0000 (GMT+00:00)
[
http://kenai.com/jira/browse/ACTIVERECORD_JDBC-18?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=49052#action_49052
]
mdub commented on ACTIVERECORD_JDBC-18:
---------------------------------------
Isn't this fixed now?
http://github.com/nicksieger/activerecord-jdbc-adapter/commit/43148222501399768ed88d2caf879f75b5e5458b
> Time is not saved with the default timezone (mssql)
> ---------------------------------------------------
>
> Key: ACTIVERECORD_JDBC-18
> URL: http://kenai.com/jira/browse/ACTIVERECORD_JDBC-18
> Project: activerecord-jdbc
> Issue Type: Bug
> Affects Versions: 0.9
> Environment: Mac OS-X. Rails 2.2. Activerecord-jdbc-adapter 0.9
> (0.9.1 has too many problems with mssql)
> Reporter: jpzwarte
>
> When setting a datetime field to Time.now or Time.now.utc and then saving
> the record, the record is saved in the app's timezone (CEST in my case).
> However, updated_at is correctly stored in UTC. The default_timezone is
> :utc.
> I traced it to the quote method in JdbcSpec::MsSQL. It calls strftime to
> convert the time to a string. If i change the strftime call to
> "value.to_s(:db)" the value is saved in UTC. My current workaround is to
> call "value.utc.strftime(....)". Hardcoding this is obviously not a
> solution.
> I looked at the quoting.rb in rails itself and it calls "value.to_s(:db)".
> It seems that that does a conversion to UTC (the default_timezone).
> Here's my rails console output demonstrating the problem:
> >> r = Result.first
> Result Load (22.0ms) SELECT TOP 1 * FROM results
> => #<Result id: 1048930496, user_id: 27, status: 3, time_taken: 9696082,
> grade: nil, incorrect_count: 0, peek_count: 0, advice: nil, created_at:
> "20090123 10:17:34", updated_at: "20090515 13:39:23", learning_object_id:
> 1028965316, begin_time: "20090123 08:18:00", end_time: "20090515 13:39:22",
> score: 4>
> >> r.end_time = Time.now
> => Fri May 15 15:40:37 0200 2009
> >> r.save
> User Load (1619.0ms) SELECT * FROM users WHERE (users.[id] = 27)
> LearningObject Load (435.0ms) SELECT * FROM learning_objects WHERE
> (learning_objects.[id] = 1028965316)
> Result Update (15.0ms) UPDATE results SET [end_time] = '20090515
> 15:40:37', [time_taken] = 9696157, [updated_at] = '20090515 13:40:41' WHERE
> [id] = 1048930496
> => true
> >> r.end_time = Time.now.utc
> => Fri May 15 13:40:52 UTC 2009
> >> r.save
> Result Update (3.0ms) UPDATE results SET [end_time] = '20090515
> 15:40:52', [time_taken] = 9696172, [updated_at] = '20090515 13:40:54' WHERE
> [id] = 1048930496
> => true
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://kenai.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
[JIRA] Commented: (ACTIVERECORD_JDBC-18) Time is not saved with the default timezone (mssql) |
mdub (JIRA) | 03/17/2010 |





