Using infinite floats in Ruby on Rails -


in rails application using sqlite3 i'd use float values float::infinity , -float::infinity in model floating point attribute. running insert queries using model.create! seems work fine, since activerecord uses prepared statements in case. however, when try update record using foo.save, activerecord doesn't use prepared stament , puts string infinity right in query, resulting in

sqlite3::sqlexception: no such column: infinity 

is there way work around or need resort using strings in model/database?

rails version 3.2.21, sqlite3 version 1.3.10


edit. changed column type string in database migration , use

serialize :property, float 

to tell activerecord store yaml-serialized floats in database, allowing store float::infinity fine.

it's because float::infinity in rails defined 1.0/0, sqlite3 doesn't know it. can use big number define infinity 9e999 replacement value you'll saving database


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -