2011/5/13 James B. Byrne <byrnejb@xxxxxxxxxxxxx>: > Actually, it turn out that 'infinity' is supported in Ruby. > Apparently infinity can be represented by assigning the value > obtained by dividing a float by zero. > > $ irb > ruby-1.8.7-p334 :001 > infinity = 1.0/0 > => Infinity > ruby-1.8.7-p334 :002 > ninfinity = -1.0/0 > => -Infinity > ruby-1.8.7-p334 :003 > > > So, I guess this now qualifies as a bug in the Ruby pg adapter gem. humm.. interesting... i did some tests here... [testdb] SELECT * from infinity_date_test; id | created_at ----+------------ 1 | infinity 2 | infinity 3 | infinity 4 | infinity 5 | 2011-05-13 --- test.rb --- require 'active_record' ActiveRecord::Base.establish_connection({ :adapter => 'postgresql', :database => 'testdb', :port => 5434, :host => 'localhost', :username => 'guedes', :password => 'guedes' }) class InfinityDateTest < ActiveRecord::Base set_table_name 'infinity_date_test' end InfinityDateTest.all.each do |row| puts "#{row.id} | #{row.created_at} | #{row.created_at.class}" end i = InfinityDateTest.new i.created_at = Date::Infinity.new i.save ---- and the output 1 | | NilClass 2 | | NilClass 3 | | NilClass 4 | | NilClass 5 | 2011-05-13 | Date /home/dba/.rvm/gems/ruby-1.9.2-p0@rails3/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract_adapter.rb:207:in `rescue in log': PGError: ERRO: sintaxe de entrada é inválida para tipo date: "--- !ruby/object:Date::Infinity (ActiveRecord::StatementInvalid) d: 1 " LINE 1: ... INTO "infinity_date_test" ("created_at") VALUES ('--- !ruby... ^ : INSERT INTO "infinity_date_test" ("created_at") VALUES ('--- !ruby/object:Date::Infinity d: 1 ') RETURNING "id" ... Well, fetching from database it came nil and when saved into, it was trying to save a serialized object. From postgresql_adapter.rb [1] you can see that it returns the correct internal type based when field type is datetime, but i can't see the same thing for 'date', i suppose that it going [2] to 'super' [3], so I suppose that this method [4] should be override in 'postgresql_adapter.rb'. [1] https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb#L85-86 [2] https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb#L117-118 [3] https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/column.rb#L253-254 [4] https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/column.rb#L197-219 Best regards, -- Dickson S. Guedes mail/xmpp: guedes@xxxxxxxxxxxxx - skype: guediz http://guedesoft.net - http://www.postgresql.org.br -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general