Hi everyone,

I'm getting some strange behaviour and I've written a small test
script which shows exactly what I mean.

I'm using ruby-1.9.2-p318 with sequel-3.30.0 and PostgreSQL-9.1.3

My code:
-------------------------------------
require 'sequel'

# DATABASE_URL => postgres://user:pass@localhost/db
DB = Sequel.connect( ENV['DATABASE_URL'] )

DB.create_table( :timestamp_test ) do
  primary_key :id
  timestamp :when, :null => false, :default => :now.sql_function
end

class Test < Sequel::Model( DB[ :timestamp_test ] )
end

begin
  test = Test.create()
  puts "Update using the class"
  Test.filter( :id => test.id ).update( :when => :now.sql_function )
  puts "\tSuccess!"
  puts "Update using the instance"
  test.update( :when => :now.sql_function )
  puts "\tSuccess!"
rescue
  puts "\tFailure!"
  raise
ensure
  DB.drop_table( :timestamp_test )
end
-------------------------------------

The output to STDOUT:
-------------------------------------
Update using the class
        Success!
Update using the instance
        Failure!
...../ruby/1.9.1/gems/sequel-3.30.0/lib/sequel/timezones.rb:179:in
`convert_input_timestamp': Invalid convert_input_timestamp type:
#<Sequel::SQL::Function @f=>:now, @args=>[]> (Sequel::InvalidValue)
        from ...../ruby/1.9.1/gems/sequel-3.30.0/lib/sequel/timezones.rb:75:in
`convert_timestamp'
        from ...../ruby/1.9.1/gems/sequel-3.30.0/lib/sequel/timezones.rb:102:in
`typecast_to_application_timestamp'
        from 
...../ruby/1.9.1/gems/sequel-3.30.0/lib/sequel/database/misc.rb:297:in
`typecast_value_datetime'
        from 
...../ruby/1.9.1/gems/sequel-3.30.0/lib/sequel/database/misc.rb:188:in
`typecast_value'
        from 
...../ruby/1.9.1/gems/sequel-3.30.0/lib/sequel/model/base.rb:1678:in
`typecast_value'
        from ...../ruby/1.9.1/gems/sequel-3.30.0/lib/sequel/model/base.rb:875:in
`[]='
        from ...../ruby/1.9.1/gems/sequel-3.30.0/lib/sequel/model/base.rb:655:in
`when='
        from 
...../ruby/1.9.1/gems/sequel-3.30.0/lib/sequel/model/base.rb:1618:in
`block in set_restricted'
        from 
...../ruby/1.9.1/gems/sequel-3.30.0/lib/sequel/model/base.rb:1615:in
`each'
        from 
...../ruby/1.9.1/gems/sequel-3.30.0/lib/sequel/model/base.rb:1615:in
`set_restricted'
        from 
...../ruby/1.9.1/gems/sequel-3.30.0/lib/sequel/model/base.rb:1686:in
`update_restricted'
        from 
...../ruby/1.9.1/gems/sequel-3.30.0/lib/sequel/model/base.rb:1263:in
`update'
        from test.rb:20:in `<main>'
-------------------------------------

Can someone help me understand what's happening here?

Thank you,
Clive Crous

-- 
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