1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Refactor add_column_options!, to move the quoting of default value for :uuid in quote_value.

This commit is contained in:
Ryuta Kamizono 2014-11-27 21:56:44 +09:00
parent 200b9035da
commit 91fca372b1

View file

@ -19,14 +19,22 @@ module ActiveRecord
sql
end
def column_options(o)
column_options = super
column_options[:array] = o.array
column_options
end
def add_column_options!(sql, options)
if options[:array] || options[:column].try(:array)
if options[:array]
sql << '[]'
end
super
end
column = options.fetch(:column) { return super }
if column.type == :uuid && options[:default] =~ /\(\)/
sql << " DEFAULT #{options[:default]}"
def quote_value(value, column)
if column.type == :uuid && value =~ /\(\)/
value
else
super
end