Module: ActiveRecord::ConnectionAdapters::SchemaStatements
- Defined in:
- lib/active_record/connection_adapters/jdbc_adapter.rb
Instance Method Summary collapse
-
#type_to_sql(type, limit = nil, precision = nil, scale = nil) ⇒ Object
The original implementation of this had a bug, which modifies native_database_types.
Instance Method Details
#type_to_sql(type, limit = nil, precision = nil, scale = nil) ⇒ Object
The original implementation of this had a bug, which modifies native_database_types. This version allows us to cache that value.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/active_record/connection_adapters/jdbc_adapter.rb', line 17 def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc: native = native_database_types[type.to_s.downcase.to_sym] column_type_sql = native.is_a?(Hash) ? native[:name] : native if type == :decimal # ignore limit, use precison and scale precision ||= native[:precision] scale ||= native[:scale] if precision if scale column_type_sql += "(#{precision},#{scale})" else column_type_sql += "(#{precision})" end else raise ArgumentError, "Error adding decimal column: precision cannot be empty if scale if specified" if scale end column_type_sql else limit ||= native[:limit] column_type_sql += "(#{limit})" if limit column_type_sql end end |