drichards@seagullharbor.com
2006-Jun-21 18:30 UTC
[Rails] SQLServer Timestamp parsing problem in sqlserver_adapter.rb
So, I''ve used Rails to tie into a legacy system which is on SQL Server 2000 with a required timestamp field, DBTimeStamp. The field is defined in SQL Server as type timestamp, but when rails is pulling it in, it appears it may be casting to a datetime format. So, when I try to read or write to the field, it gives me a parsing error: NoMethodError: private method ''gsub!'' called for [0, 0, 0, 0, 0, 0, 224, 43]:Array from c:/ruby/lib/ruby/1.8/date/format.rb:253:in ''_parse'' from c:/ruby/lib/ruby/1.8/parsedate.rb:9:in ''parsedate'' from c:/ruby/lib/ruby/1.8/gems/activerecord-1.14.2/lib/active_record_cnnection_adapters/sqlserver_adapter.rb:92:in ''cast_to_time'' from c:/ruby/lib/ruby/1.8/gems/activerecord-1.14.2/lib/active_record_cnnection_adapters/sqlserver_adapter.rb:82:in ''type_cast'' ... I think the problem comes down to sqlserver_adapter.rb, in the type_cast method, asking timestamps to cast_to_time instead of something that SQLServer is expecting. My questions are two: 1) Does it look like I''ve traced this right? 2) Who knows how a timestamp record needs to be casted in SQLServer? I''ve looked at the data in a third-party tool, and it doesn''t give me much: data of type BYTES (binary data?). I''ve spent quite a bit of time over at Microsoft''s site today, but it seems they''ve either started moving things around, or they''ve got some servers under maintenance, because I''ve got blind links everywhere. Thanks in advance for your comments.