Forum: Ruby on Rails datetime fixture format for Mysql 5.0

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Forrest C. (Guest)
on 2006-06-08 21:16
(Received via mailing list)
Hi All:

I develop on several machines, most have Mysql 4.* and one has Mysql
5.0.  On 4.*, the following erb for a fixture works fine:

  updated_at: <%= 1.days.ago.to_s:db%>

But fails on 5.0.  I had a similar deal when I had date fixtures, and
switched forrmats so that both 4.* and 5.0 were happy.  is there
to_s:db_works_for_mysql_50() ? or similar?

Thanks

Forrest
Alex W. (Guest)
on 2006-06-08 21:27
Forrest C. wrote:
> Hi All:
>
> I develop on several machines, most have Mysql 4.* and one has Mysql
> 5.0.  On 4.*, the following erb for a fixture works fine:
>
>   updated_at: <%= 1.days.ago.to_s:db%>
>
> But fails on 5.0.  I had a similar deal when I had date fixtures, and
> switched forrmats so that both 4.* and 5.0 were happy.  is there
> to_s:db_works_for_mysql_50() ? or similar?
>
> Thanks
>
> Forrest

I use the following with mysql d.0 with no problems

  updated_at: <%= 1.days.ago.to_formatted_s(:db) %>
Alex W. (Guest)
on 2006-06-08 21:27
Alex W. wrote:
> Forrest C. wrote:
>> Hi All:
>>
>> I develop on several machines, most have Mysql 4.* and one has Mysql
>> 5.0.  On 4.*, the following erb for a fixture works fine:
>>
>>   updated_at: <%= 1.days.ago.to_s:db%>
>>
>> But fails on 5.0.  I had a similar deal when I had date fixtures, and
>> switched forrmats so that both 4.* and 5.0 were happy.  is there
>> to_s:db_works_for_mysql_50() ? or similar?
>>
>> Thanks
>>
>> Forrest
>
> I use the following with mysql d.0 with no problems
>
>   updated_at: <%= 1.days.ago.to_formatted_s(:db) %>

oops
5.0, not d.0
Forrest C. (Guest)
on 2006-06-08 21:48
(Received via mailing list)
They both seem to have the same format in script/console.   I made the
change but still get the error below.  I notice what's being inserted
is different than what comes out of script/console


  1) Error:
test_pattern(PatternViewedMetricTest):
ActiveRecord::StatementInvalid: Mysql::Error: #22007Incorrect datetime
value: '2006-06-08T10:40:13-0700' for column 'updated_at' at row 1:
INSERT INTO pattern_viewed_metrics (`updated_at`, `pattern_id`, `id`,
`person_id`) VALUES ('2006-06-08T10:40:13-0700', 2, 2, 1)

Any ideas?
Forrest C. (Guest)
on 2006-06-09 00:44
(Received via mailing list)
I'm an idiot.  I had one field called DateTime.now.to_formatted_s(:db)
which was the culprit.

Everything works
This topic is locked and can not be replied to.