diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-09-16 20:07:28 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-09-16 20:07:28 -0700 |
commit | beaac33f9ff732fc01ebdb84ff66a529b79fa118 (patch) | |
tree | 4632932a6ce826a8b057df55bd98ae762026103d /activerecord/lib/active_record/schema_dumper.rb | |
parent | 4434e3f72b14cc9fdbd3bd5afa0784406c1c305b (diff) | |
parent | 4544d2bc90bea93c38bb21d912dba00f51cf620f (diff) | |
download | rails-beaac33f9ff732fc01ebdb84ff66a529b79fa118.tar.gz rails-beaac33f9ff732fc01ebdb84ff66a529b79fa118.tar.bz2 rails-beaac33f9ff732fc01ebdb84ff66a529b79fa118.zip |
Merge pull request #7547 from danmcclain/pg-arrays
Adds migration and type casting support for PostgreSQL Array datatype
Diffstat (limited to 'activerecord/lib/active_record/schema_dumper.rb')
-rw-r--r-- | activerecord/lib/active_record/schema_dumper.rb | 31 |
1 files changed, 2 insertions, 29 deletions
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb index 310b4c1459..36bde44e7c 100644 --- a/activerecord/lib/active_record/schema_dumper.rb +++ b/activerecord/lib/active_record/schema_dumper.rb @@ -107,27 +107,11 @@ HEADER column_specs = columns.map do |column| raise StandardError, "Unknown type '#{column.sql_type}' for column '#{column.name}'" if @types[column.type].nil? next if column.name == pk - spec = {} - spec[:name] = column.name.inspect - - # AR has an optimization which handles zero-scale decimals as integers. This - # code ensures that the dumper still dumps the column as a decimal. - spec[:type] = if column.type == :integer && /^(numeric|decimal)/ =~ column.sql_type - 'decimal' - else - column.type.to_s - end - spec[:limit] = column.limit.inspect if column.limit != @types[column.type][:limit] && spec[:type] != 'decimal' - spec[:precision] = column.precision.inspect if column.precision - spec[:scale] = column.scale.inspect if column.scale - spec[:null] = 'false' unless column.null - spec[:default] = default_string(column.default) if column.has_default? - (spec.keys - [:name, :type]).each{ |k| spec[k].insert(0, "#{k.to_s}: ")} - spec + @connection.column_spec(column, @types) end.compact # find all migration keys used in this table - keys = [:name, :limit, :precision, :scale, :default, :null] + keys = @connection.migration_keys # figure out the lengths for each column based on above keys lengths = keys.map { |key| @@ -170,17 +154,6 @@ HEADER stream end - def default_string(value) - case value - when BigDecimal - value.to_s - when Date, DateTime, Time - "'#{value.to_s(:db)}'" - else - value.inspect - end - end - def indexes(table, stream) if (indexes = @connection.indexes(table)).any? add_index_statements = indexes.map do |index| |