提交 29ae3e90 编写于 作者: J Jeremy Kemper

Schema dumper quotes date :default values.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4650 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 49f44daf
*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]
......
......@@ -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|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册