diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2014-11-27 21:56:44 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2014-11-28 11:21:08 +0900 |
commit | 91fca372b14b553a8029d81213ff51c8f3cde39b (patch) | |
tree | f34622d21497add740966514216655ab1995cdb6 | |
parent | 200b9035daa81535d385544b1ce8f3cfa17d0a33 (diff) | |
download | rails-91fca372b14b553a8029d81213ff51c8f3cde39b.tar.gz rails-91fca372b14b553a8029d81213ff51c8f3cde39b.tar.bz2 rails-91fca372b14b553a8029d81213ff51c8f3cde39b.zip |
Refactor `add_column_options!`, to move the quoting of default value for :uuid in `quote_value`.
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb index 193c950261..89b7f0a6b7 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb @@ -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 |