Skip to content
Browse files

Schema dumper quotes date :default values.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4650 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 49f44da commit 29ae3e90988a9edf09d85ed32d5aac76fa199341 @jeremy jeremy committed Aug 2, 2006
Showing with 14 additions and 1 deletion.
  1. +2 −0 activerecord/CHANGELOG
  2. +12 −1 activerecord/lib/active_record/schema_dumper.rb
View
2 activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Schema dumper quotes date :default values. [Dave Thomas]
+
* Calculate sum with SQL, not Enumerable on HasManyThrough Associations. [Dan Peterson]
* Factor the attribute#{suffix} methods out of method_missing for easier extension. [Jeremy Kemper]
View
13 activerecord/lib/active_record/schema_dumper.rb
@@ -95,7 +95,7 @@ def table(table, stream)
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 @@ def table(table, stream)
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|

0 comments on commit 29ae3e9

Please sign in to comment.
Something went wrong with that request. Please try again.