|
From: Matthew B. <ma...@by...> - 2003-06-22 11:45:58
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi there,
There's a bug in lib/dbi/sql.rb which throws an exception instead of
returning a null when SELECTing the timestamp "00:00:00", at least it gives
me this error:
> ERROR: no implicit conversion from nil
> /usr/lib/ruby/1.6/dbi/sql.rb:59:in `gm'
> /usr/lib/ruby/1.6/dbi/sql.rb:59:in `as_timestamp'
> /usr/lib/ruby/1.6/dbi/sql.rb:51:in `as_time'
> /usr/lib/ruby/1.6/dbi/sql.rb:79:in `send'
> /usr/lib/ruby/1.6/dbi/sql.rb:79:in `coerce'
> /usr/lib/ruby/1.6/DBD/Mysql/Mysql.rb:377:in `fill_array'
> /usr/lib/ruby/1.6/DBD/Mysql/Mysql.rb:374:in `each_with_index'
> /usr/lib/ruby/1.6/DBD/Mysql/Mysql.rb:374:in `each'
> /usr/lib/ruby/1.6/DBD/Mysql/Mysql.rb:374:in `each_with_index'
> /usr/lib/ruby/1.6/DBD/Mysql/Mysql.rb:374:in `fill_array'
> /usr/lib/ruby/1.6/DBD/Mysql/Mysql.rb:384:in `fetch'
> /usr/lib/ruby/1.6/dbi/dbi.rb:786:in `fetch'
> /usr/lib/ruby/1.6/dbi/dbi.rb:811:in `each'
> /usr/lib/ruby/1.6/dbi/dbi.rb:639:in `select_all'
> /usr/lib/ruby/1.6/dbi/dbi.rb:637:in `execute'
> /usr/lib/ruby/1.6/dbi/dbi.rb:637:in `select_all'
> /home/vmadmin/scripts/deliver-dbmail:110
For now I've added these checks to make it return nil values correctly, but
I'm not sure it gets to the heart of the problem. May look again at the
problem towards the end of the week but maybe the author will know the issue
more precisely than me!
def as_time(str)
return nil if str.nil?
t = as_timestamp(str)
+ return nil if t.nil?
DBI::Time.new(t.hour, t.min, t.sec)
end
def as_timestamp(str)
return nil if str.nil? or str.empty?
ary = ParseDate.parsedate(str)
+ return nil if ary.nil? || ary[0].nil?
time = ::Time.gm(*(ary[0,6]))
if ary[6] =~ /^(\+|\-)\d+$/
diff = ary[6].to_i * 60 * 60
time -= diff
time.localtime
end
DBI::Timestamp.new(time)
end
cheers,
- --
Matthew Bloch Bytemark Hosting
tel. +44 (0) 8707 455026
http://www.bytemark-hosting.co.uk/
Dedicated Linux hosts from 15ukp ($26) per month
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+9Za7T2rVDg8aLXQRAnSHAJ9+kCQGfqw1N/iu33LvPfBxukPeVwCfePIb
rgoOXCNUlmu3bjGga2enu8c=
=aV4q
-----END PGP SIGNATURE-----
|