Say I have a table in postgres 8.4

create table entries (
  id int primary key,
   start time without time zone
);

and a model

class Entry < Sequel::Model; end

assuming there is some data in the table, Entry.first.start returns a
SQLTime, which is fine.

But in ruby-1.9.2-p290

e = Entry.first
e.start = Time.now

fails with

Sequel::InvalidValue: ArgumentError: argument out of range
        from
/usr/lib/ruby/gems/1.9.1/gems/gems/sequel-3.27.0/lib/sequel/database/misc.rb:281:in
`local'
        from
/usr/lib/ruby/gems/1.9.1/gems/gems/sequel-3.27.0/lib/sequel/database/misc.rb:281:in
`typecast_value_time'
        from
/usr/lib/ruby/gems/1.9.1/gems/gems/sequel-3.27.0/lib/sequel/database/misc.rb:124:in
`typecast_value'
        from
/usr/lib/ruby/gems/1.9.1/gems/gems/sequel-3.27.0/lib/sequel/model/base.rb:1606:in
`typecast_value'
        from
/usr/lib/ruby/gems/1.9.1/gems/gems/sequel-3.27.0/lib/sequel/model/base.rb:827:in
`[]='
        from
/usr/lib/ruby/gems/1.9.1/gems/gems/sequel-3.27.0/lib/sequel/model/base.rb:606:in
`start='
        from (irb):12
        from /usr/bin/irb:16:in `<main>'

The relevant line is

SQLTime.local(value.year, value.month, value.day, value.hour, value.min,
value.sec, value.respond_to?(:nsec) ? value.nsec : value.usec)

and a fix might be

SQLTime.local(value.year, value.month, value.day, value.hour, value.min,
value.sec, value.respond_to?(:nsec) ? value.nsec*1e-9 : value.usec*1e-6)

bye
John

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to