From: Paul D. <pa...@sn...> - 2003-04-27 18:04:20
|
At 10:37 -0700 4/27/03, Michael Neumann wrote: >Update of /cvsroot/ruby-dbi/src/lib/dbi >In directory sc8-pr-cvs1:/tmp/cvs-serv23497 > >Modified Files: > sql.rb >Log Message: >Fixed bug in DBI::SQL::BasicQuote::Coerce#as_time >Mysql time columns (like "13:32:33") could not be converted into >DBI::Time objects >(thanks to Tim Bates) Speaking of coercion... I've noticed that MySQL DATETIME and TIMESTAMP values get converted into formats that don't really reflect how MySQL itself displays them. For example, a DATETIME value such as '2001-01-01 00:00:00' gets coerced to '2001-1-1 0:0:0.0'. Leading zeros are lost, and a fraction-of-seconds part is added at the end. Should this be considered a bug, or just something that MySQL users should be aware of, and wary of? > > >Index: sql.rb >=================================================================== >RCS file: /cvsroot/ruby-dbi/src/lib/dbi/sql.rb,v >retrieving revision 1.13 >retrieving revision 1.14 >diff -u -r1.13 -r1.14 >--- sql.rb 1 Feb 2003 13:45:23 -0000 1.13 >+++ sql.rb 27 Apr 2003 17:37:02 -0000 1.14 >@@ -47,9 +47,9 @@ > end > > def as_time(str) >- return nil if str.nil? >- t = as_timestamp(str) >- DBI::Time.new(t.hour, t.min, t.sec) >+ return nil if str.nil? or str.empty? >+ t = ParseDate.parsedate(str) >+ DBI::Time.new(*t[3,3]) > end > |