rsim/oracle-enhanced — Issue #109: Exception when creating a model in Rails 3.1.1 with a decimal column
Author: awd-switzerland
Created: 2011-10-25 14:04:10+00:00
State: open

We can reproduce the issue with the following snippet:

ActiveRecord::Migration.create_table "test_decimals", :force => true do |t|
t.decimal "some_column", :precision => 15, :scale => 3
end
class TestDecimals < ActiveRecord::Base; end

# works
r = TestDecimals.create
r.some_column = 1.5
r.save

# fails
TestDecimals.create :some_column => 1.5
SQL (1.5ms) INSERT INTO "TEST_DECIMALS" ("ID", "SOME_COLUMN") VALUES (:a1, :a2) [["id", 10001], ["some_column", #]]
ActiveRecord::StatementInvalid: OCIError: ORA-01722: invalid number: INSERT INTO "TEST_DECIMALS" ("ID", "SOME_COLUMN") VALUES (:a1, :a2)
from stmt.c:312:in oci8lib_191.bundle
from /Users/sdd/.rvm/gems/ruby-1.9.2-p290/gems/ruby-oci8-2.0.6/lib/oci8/oci8.rb:288:in `exec'
from /Users/sdd/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-oracle_enhanced-adapter-1.4.0/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:145:in `exec_update'
from /Users/sdd/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-oracle_enhanced-adapter-1.4.0/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:671:in `block in exec_insert'
from /Users/sdd/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:244:in `block in log'
from /Users/sdd/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
from /Users/sdd/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:239:in `log'
from /Users/sdd/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-oracle_enhanced-adapter-1.4.0/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1226:in `log'
from /Users/sdd/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-oracle_enhanced-adapter-1.4.0/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:653:in `exec_insert'
from /Users/sdd/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:90:in `insert'

The software used are:
* ruby 1.9.2 p290
* ruby on rails 3.1.1
* ruby oci8 2.0.6
* activerecord-oracle_enhanced-adapter 1.4.0
* oracle version 10g 10.2.0.4

We are not entirely sure whether this might be a bug in oci8 instead of the adapter.

Thank you for having a look at the issue. If we can be of any assistance, please don't hesitate to ask. We will gladly help.

Best regards
Stefan Rusterholz