aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2014-05-12 17:28:45 +0200
committerYves Senn <yves.senn@gmail.com>2014-05-12 17:28:45 +0200
commit096be96db894854a199ce8cf9a8edeca0f203966 (patch)
treea8515782cd8f5a8e211c23390745a171970915af /activerecord/lib
parent711af752342cdd558f5f82d407d0d56a115bb8bc (diff)
downloadrails-096be96db894854a199ce8cf9a8edeca0f203966.tar.gz
rails-096be96db894854a199ce8cf9a8edeca0f203966.tar.bz2
rails-096be96db894854a199ce8cf9a8edeca0f203966.zip
pg, `change_column_default` accepts `[]`. Closes #11586.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb4
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb1
2 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb b/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
index 403e37fde9..fa458d0243 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
@@ -187,8 +187,8 @@ module ActiveRecord
def quote_default_value(value, column) #:nodoc:
if column.type == :uuid && value =~ /\(\)/
value
- else
- quote(value)
+ else
+ quote(value, column)
end
end
end
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 d26e0b7635..5bf4c7afd6 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
@@ -405,6 +405,7 @@ module ActiveRecord
def change_column_default(table_name, column_name, default)
clear_cache!
column = column_for(table_name, column_name)
+
execute "ALTER TABLE #{quote_table_name(table_name)} ALTER COLUMN #{quote_column_name(column_name)} SET DEFAULT #{quote_default_value(default, column)}" if column
end