jasonmk / datastax_rails

A Ruby-on-Rails interface to Datastax Enterprise. Replaces the majority of ActiveRecord functionality.
MIT License
23 stars 9 forks source link

Float values in Maps #34

Open davidkelley opened 9 years ago

davidkelley commented 9 years ago

Hi, when attempting to use Float's inside Maps, I'm getting the following error:

undefined method 'encode' for 2.107:Float

Are maps not intended to store floats or is this a bug?

I've included the stack trace below, any help you can provide is greatly appreciated.

# /usr/local/lib/ruby/gems/2.1.0/gems/cql-rb-1.2.2/lib/cql/protocol/type_converter.rb:322:in `varchar_to_bytes'
     # /usr/local/lib/ruby/gems/2.1.0/gems/cql-rb-1.2.2/lib/cql/protocol/type_converter.rb:76:in `call'
     # /usr/local/lib/ruby/gems/2.1.0/gems/cql-rb-1.2.2/lib/cql/protocol/type_converter.rb:76:in `to_bytes'
     # /usr/local/lib/ruby/gems/2.1.0/gems/cql-rb-1.2.2/lib/cql/protocol/type_converter.rb:62:in `block in to_bytes'
     # /usr/local/lib/ruby/gems/2.1.0/gems/cql-rb-1.2.2/lib/cql/protocol/type_converter.rb:60:in `each'
     # /usr/local/lib/ruby/gems/2.1.0/gems/cql-rb-1.2.2/lib/cql/protocol/type_converter.rb:60:in `to_bytes'
     # /usr/local/lib/ruby/gems/2.1.0/gems/cql-rb-1.2.2/lib/cql/protocol/requests/execute_request.rb:51:in `block in encode_body'
     # /usr/local/lib/ruby/gems/2.1.0/gems/cql-rb-1.2.2/lib/cql/protocol/requests/execute_request.rb:50:in `each'
     # /usr/local/lib/ruby/gems/2.1.0/gems/cql-rb-1.2.2/lib/cql/protocol/requests/execute_request.rb:50:in `each_with_index'
     # /usr/local/lib/ruby/gems/2.1.0/gems/cql-rb-1.2.2/lib/cql/protocol/requests/execute_request.rb:50:in `encode_body'
     # /usr/local/lib/ruby/gems/2.1.0/gems/cql-rb-1.2.2/lib/cql/protocol/requests/execute_request.rb:15:in `initialize'
     # /usr/local/lib/ruby/gems/2.1.0/gems/cql-rb-1.2.2/lib/cql/client/asynchronous_prepared_statement.rb:66:in `new'
     # /usr/local/lib/ruby/gems/2.1.0/gems/cql-rb-1.2.2/lib/cql/client/asynchronous_prepared_statement.rb:66:in `run'
     # /usr/local/lib/ruby/gems/2.1.0/gems/cql-rb-1.2.2/lib/cql/client/asynchronous_prepared_statement.rb:29:in `execute'
     # /usr/local/lib/ruby/gems/2.1.0/gems/cql-rb-1.2.2/lib/cql/client/synchronous_prepared_statement.rb:15:in `block in execute'
     # /usr/local/lib/ruby/gems/2.1.0/gems/cql-rb-1.2.2/lib/cql/client/synchronous_client.rb:8:in `synchronous_backtrace'
     # /usr/local/lib/ruby/gems/2.1.0/gems/cql-rb-1.2.2/lib/cql/client/synchronous_prepared_statement.rb:15:in `execute'
     # /usr/local/lib/ruby/gems/2.1.0/gems/datastax_rails-2.0.9/lib/datastax_rails/cql/base.rb:34:in `execute'
     # /usr/local/lib/ruby/gems/2.1.0/gems/datastax_rails-2.0.9/lib/datastax_rails/persistence.rb:108:in `write_with_cql'
     # /usr/local/lib/ruby/gems/2.1.0/gems/datastax_rails-2.0.9/lib/datastax_rails/persistence.rb:69:in `block (2 levels) in write'
     # /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/notifications.rb:161:in `instrument'
     # /usr/local/lib/ruby/gems/2.1.0/gems/datastax_rails-2.0.9/lib/datastax_rails/persistence.rb:65:in `block in write'
     # /usr/local/lib/ruby/gems/2.1.0/gems/datastax_rails-2.0.9/lib/datastax_rails/persistence.rb:64:in `tap'
     # /usr/local/lib/ruby/gems/2.1.0/gems/datastax_rails-2.0.9/lib/datastax_rails/persistence.rb:64:in `write'
     # /usr/local/lib/ruby/gems/2.1.0/gems/datastax_rails-2.0.9/lib/datastax_rails/persistence.rb:254:in `_write'
     # /usr/local/lib/ruby/gems/2.1.0/gems/datastax_rails-2.0.9/lib/datastax_rails/persistence.rb:242:in `_create_record'
     # /usr/local/lib/ruby/gems/2.1.0/gems/datastax_rails-2.0.9/lib/datastax_rails/callbacks.rb:290:in `block in _create_record'
     # /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:82:in `run_callbacks'
     # /usr/local/lib/ruby/gems/2.1.0/gems/datastax_rails-2.0.9/lib/datastax_rails/callbacks.rb:290:in `_create_record'
     # /usr/local/lib/ruby/gems/2.1.0/gems/datastax_rails-2.0.9/lib/datastax_rails/timestamps.rb:36:in `_create_record'
     # /usr/local/lib/ruby/gems/2.1.0/gems/datastax_rails-2.0.9/lib/datastax_rails/persistence.rb:235:in `_create_or_update'
     # /usr/local/lib/ruby/gems/2.1.0/gems/datastax_rails-2.0.9/lib/datastax_rails/callbacks.rb:286:in `block in _create_or_update'
     # /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:113:in `call'
     # /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:113:in `call'
     # /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:166:in `block in halting'
     # /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:86:in `call'
     # /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/callbacks.rb:86:in `run_callbacks'
     # /usr/local/lib/ruby/gems/2.1.0/gems/datastax_rails-2.0.9/lib/datastax_rails/callbacks.rb:286:in `_create_or_update'
     # /usr/local/lib/ruby/gems/2.1.0/gems/datastax_rails-2.0.9/lib/datastax_rails/persistence.rb:135:in `save'
     # /usr/local/lib/ruby/gems/2.1.0/gems/datastax_rails-2.0.9/lib/datastax_rails/attribute_methods/dirty.rb:15:in `save'
     # /usr/local/lib/ruby/gems/2.1.0/gems/datastax_rails-2.0.9/lib/datastax_rails/validations.rb:39:in `save'
     # /usr/local/lib/ruby/gems/2.1.0/gems/datastax_rails-2.0.9/lib/datastax_rails/persistence.rb:192:in `update_attributes'
jasonmk commented 9 years ago

Hmmm, sounds like a bug. I'll take a look tomorrow. There's definitely no reason floats shouldn't work in a map.