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.
37a786a2425b62259869a86adf5219bb?d=identicon&s=25 Forrest Chang (Guest)
on 2006-06-08 19: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
D0cd6b10e01bacb976b3b815a9c660bc?d=identicon&s=25 Alex Wayne (Guest)
on 2006-06-08 19:27
Forrest Chang 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) %>
D0cd6b10e01bacb976b3b815a9c660bc?d=identicon&s=25 Alex Wayne (Guest)
on 2006-06-08 19:27
Alex Wayne wrote:
> Forrest Chang 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
37a786a2425b62259869a86adf5219bb?d=identicon&s=25 Forrest Chang (Guest)
on 2006-06-08 19: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?
37a786a2425b62259869a86adf5219bb?d=identicon&s=25 Forrest Chang (Guest)
on 2006-06-08 22: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.