1 # AR's 2.2 version of this method is sufficient, but we need it for
3 if ActiveRecord::VERSION::MAJOR <= 2 && ActiveRecord::VERSION::MINOR < 2
5 module ConnectionAdapters # :nodoc:
6 module SchemaStatements
7 # Convert the speficied column type to a SQL string.
8 def type_to_sql(type, limit = nil, precision = nil, scale = nil)
9 if native = native_database_types[type]
10 column_type_sql = (native.is_a?(Hash) ? native[:name] : native).dup
12 if type == :decimal # ignore limit, use precision and scale
13 scale ||= native[:scale]
15 if precision ||= native[:precision]
17 column_type_sql << "(#{precision},#{scale})"
19 column_type_sql << "(#{precision})"
22 raise ArgumentError, "Error adding decimal column: precision cannot be empty if scale if specified"
25 elsif limit ||= native.is_a?(Hash) && native[:limit]
26 column_type_sql << "(#{limit})"
40 module ConnectionAdapters
41 module CompatibilityMethods
42 def self.needed?(base)
43 !base.instance_methods.include?("quote_table_name")
46 def quote_table_name(name)
47 quote_column_name(name)