Skip to content
This repository

Bug when NUMERIC type has a SCALE of nil #165

wants to merge 2 commits into from

3 participants

Cory Foy Raimonds Simanovskis Yasuo Honda
Cory Foy

This commit fixes an issue where we have a NUMERIC column with a SCALE of nil that was being considered a BigDecimal instead of an integer

Cory Foy

I'm working on providing a test case too - I couldn't get bundler to install the gems for some reason. Will get that soon.

Raimonds Simanovskis
rsim commented April 28, 2012

Yes, please add test case as I try to have test coverage for all edge cases.

Cory Foy

I can't actually add any test cases - I'm on Lion, so there's no support for Oracle. Also, I had to modify the Gemfile to get bundle to install (see rails/rails#6039). However, both of these commits were production bugs which were fixed with the above code. I'd be happy to share more details if you'd like.

Yasuo Honda

If it is still an issue, please update your pull request with necessary tests.
Tests make sure what your code fix and also it prevents from future regressions by other changes.

There are some info how to install ruby-oci8 on Lion. ( I'm not using Oracle client with Mac, I do not have any answer how to install ruby-oci8/Oracle client on Lion, though). Or installing VirtualBox on your Mac and you can run any Linux(CentOS, Oracle Linux).

rails/rails#6039 issus has been resolved, bundler should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
2  lib/active_record/connection_adapters/oracle_enhanced_adapter.rb
@@ -870,7 +870,7 @@ def write_lobs(table_name, klass, attributes) #:nodoc:
870 870
         if is_with_cpk
871 871
           id = {|pk| attributes[pk.to_s] }
872 872
-          id = quote(attributes[klass.primary_key])
+          id = quote(attributes[klass.primary_key.to_s]) #fix or else it can't find it if attributes are quoted and this is a symbol
874 874
875 875 { |col| col.sql_type =~ /LOB$/i }.each do |col|
876 876
           value = attributes[]
7  lib/active_record/connection_adapters/oracle_enhanced_column.rb
@@ -62,13 +62,18 @@ def comment
62 62
63 63
64 64
+      def scale_present?(field_type)
+        scale = extract_scale(field_type)
+        return scale.nil? || scale == 0
+      end
65 70
       def simplified_type(field_type)
66 71
         forced_column_type ||
67 72
         case field_type
68 73
         when /decimal|numeric|number/i
69 74
           if OracleEnhancedAdapter.emulate_booleans && field_type == 'NUMBER(1)'
70 75
-          elsif extract_scale(field_type) == 0 ||
+          elsif scale_present?(field_type) ||
72 77
                 # if column name is ID or ends with _ID
73 78
                 OracleEnhancedAdapter.emulate_integers_by_column_name && OracleEnhancedAdapter.is_integer_column?(name, table_name)
74 79

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.