Glad you can move on. BTW, the activerecord-sqlserver-adapter, that's hard stuff. I still have a fork in my Github account (https://github.com/iox/activerecord-sqlserver-adapter) with some hacks to make it work with Sqlserver 2000. You can see really weird things while using it :).
Warm regards, Ignacio El 28/01/14 19:25, Tim Griffin escribió: > Hi Ignacio; > > To complicate matters, yes, your examples work below from my Rails > application (and in the Rails console). In fact, no problems operating > with this rich type against my PostgreSQL-based Rails application. > > But, my issue is occurring in the /non-rails/ world. I simply have a > ruby application that uses: > > gem 'activerecord', '~> 4.0.2' > gem 'activesupport', '~> 4.0.2' > gem 'rake', '0.9.2.2' > gem 'tiny_tds' > gem 'activerecord-sqlserver-adapter', :git => > 'https://github.com/rails-sqlserver/activerecord-sqlserver-adapter.git', > :branch => 'master' > gem 'hobo_support', '2.1.0' > gem 'hobo_fields', '2.1.0' > gem 'pg', '0.17.1' > gem 'activerecord-postgresql-adapter', '~> 0.0.1' > > The class of the mtg_amount being passed into my newInstrument (in my > Ruby application) is quite definitely BigDecimal: > > #<BigDecimal:7f87bf190750,'0.17200501E6',18(54)> > > Just baffling. > > Anyway, at this stage, it'll be easy for me to remove the Dollars class > from my conversion app (I don't depend on its functionality here), and > get on with it! > > Tim > > > > On Tuesday, January 28, 2014 1:03:34 PM UTC-5, Ignacio Huerta wrote: > > Hi Tim, > > Does it work if you do something like this in the console? > > newInstrument = Instrument.new( > :mtg_amount => 10, > ... > newInstrument.save! > > Or > > newInstrument = Instrument.new( > :mtg_amount => 10.50, > ... > newInstrument.save! > > > If it works, then maybe the object returned by > get_mtg_amount(sql_server_record) is not what is should be and maybe > you > can convert it. > > You can also check: > > logger.info <http://logger.info> > get_mtg_amount(sql_server_record).class > > If I could reproduce it in my system, I would gladly try to debug it. > > Regards, > Ignacio > > El 28/01/14 18:32, Tim Griffin escribió: > > Hi all; > > > > I'm working to convert an application from MySQL to PostgreSQL and > have > > a hit a problem with my use of a Hobo rich type: > > > > class Dollars < DelegateClass(BigDecimal) > > COLUMN_TYPE = :decimal > > HoboFields.register_type(:dollars, self) > > end > > > > > > I use the Dollars class in a model as follows: > > > > fields > > mtg_amount :dollars, :precision => 12, :scale => 2, :default => 0 > > end > > > > In a conversion application I wrote to move data from SQL Server into > > PostgreSQL, I'm hitting an issue I really don't know how to address > > (other than doing away with the Dollars class): > > > > During the insert of a new record that includes a mtg_amount value > (such > > as this) > > > > newInstrument = Instrument.new( > > :mtg_amount => get_mtg_amount(sql_server_record), > > ... > > newInstrument.save! > > > > > > I'm getting: > > > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/quoting.rb:76:in > > > `type_cast': can't cast Dollars to decimal (TypeError) > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/connection_adapters/postgresql/quoting.rb:120:in > > > `type_cast' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/connection_adapters/postgresql_adapter.rb:783:in > > > `block in exec_cache' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/connection_adapters/postgresql_adapter.rb:782:in > > > `map' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/connection_adapters/postgresql_adapter.rb:782:in > > > `exec_cache' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:139:in > > > `block in exec_query' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:435:in > > > `block in log' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-4.0.2/lib/active_support/notifications/instrumenter.rb:20:in > > > `instrument' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:430:in > > > `log' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:137:in > > > `exec_query' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:184:in > > > `exec_insert' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:96:in > > > `insert' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in > > > `insert' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/relation.rb:76:in > > > `insert' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/persistence.rb:509:in > > > `create_record' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/attribute_methods/dirty.rb:78:in > > > `create_record' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/callbacks.rb:306:in > > > `block in create_record' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:373:in > > > `_run__4347159504384664941__create__callbacks' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:80:in > > > `run_callbacks' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/callbacks.rb:306:in > > > `create_record' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/timestamp.rb:57:in > > > `create_record' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/persistence.rb:477:in > > > `create_or_update' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/callbacks.rb:302:in > > > `block in create_or_update' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:433:in > > > `_run__4347159504384664941__save__callbacks' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:80:in > > > `run_callbacks' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/callbacks.rb:302:in > > > `create_or_update' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/persistence.rb:128:in > > > `save!' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/validations.rb:57:in > > > `save!' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/attribute_methods/dirty.rb:41:in > > > `save!' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/transactions.rb:275:in > > > `block in save!' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/transactions.rb:326:in > > > `block in with_transaction_returning_status' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in > > > `block in transaction' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in > > > `within_new_transaction' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in > > > `transaction' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/transactions.rb:209:in > > > `transaction' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/transactions.rb:323:in > > > `with_transaction_returning_status' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/transactions.rb:275:in > > > `save!' > > from > > > > /Volumes/HD/Users/tgriffin/Sites/daybook2polar/lib/convert_instruments.rb:92:in > > > `block in convert_instruments' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/relation/delegation.rb:13:in > > > `each' > > from > > > > /Users/tgriffin/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-4.0.2/lib/active_record/relation/delegation.rb:13:in > > > `each' > > from > > > > /Volumes/HD/Users/tgriffin/Sites/daybook2polar/lib/convert_instruments.rb:22:in > > > `convert_instruments' > > > > I just don't understand enough of the mechanism that ActiveRecord is > > using at this stage. If "dollars" is already a decimal, what's the > big deal? > > > > Many thanks, > > Tim > > > > > > -- > > You received this message because you are subscribed to the Google > > Groups "Hobo Users" group. > > To unsubscribe from this group and stop receiving emails from it, > send > > an email to [email protected] <javascript:>. > > To post to this group, send email to [email protected] > <javascript:>. > > Visit this group at http://groups.google.com/group/hobousers > <http://groups.google.com/group/hobousers>. > > For more options, visit https://groups.google.com/groups/opt_out > <https://groups.google.com/groups/opt_out>. > > -- > Ignacio Huerta Arteche > http://www.ihuerta.net > Teléfono: 0034 645 70 77 35 > Email realizado con software libre > > -- > You received this message because you are subscribed to the Google > Groups "Hobo Users" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/hobousers. > For more options, visit https://groups.google.com/groups/opt_out. -- Ignacio Huerta Arteche http://www.ihuerta.net Teléfono: 0034 645 70 77 35 Email realizado con software libre -- You received this message because you are subscribed to the Google Groups "Hobo Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/hobousers. For more options, visit https://groups.google.com/groups/opt_out.
