diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-08-02 20:20:38 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-08-02 20:20:38 +0000 |
commit | 29ae3e90988a9edf09d85ed32d5aac76fa199341 (patch) | |
tree | 4a6651576b0dcecc3ae25aa2bea1569c7ec45e74 /activerecord/lib | |
parent | 49f44daf174ab18e00d16e9df1b153b660483261 (diff) | |
download | rails-29ae3e90988a9edf09d85ed32d5aac76fa199341.tar.gz rails-29ae3e90988a9edf09d85ed32d5aac76fa199341.tar.bz2 rails-29ae3e90988a9edf09d85ed32d5aac76fa199341.zip |
Schema dumper quotes date :default values.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4650 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/schema_dumper.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb index 2d31b5d88e..98c1163458 100644 --- a/activerecord/lib/active_record/schema_dumper.rb +++ b/activerecord/lib/active_record/schema_dumper.rb @@ -95,7 +95,7 @@ HEADER spec[:precision] = column.precision.inspect if !column.precision.nil? spec[:scale] = column.scale.inspect if !column.scale.nil? spec[:null] = 'false' if !column.null - spec[:default] = (column.default.is_a?(BigDecimal) ? column.default.to_s : column.default.inspect) if !column.default.nil? + spec[:default] = default_string(column.default) if !column.default.nil? (spec.keys - [:name, :type]).each{ |k| spec[k].insert(0, "#{k.inspect} => ")} spec end.compact @@ -125,6 +125,17 @@ 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) indexes = @connection.indexes(table) indexes.each do |index| |