aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2015-08-28 15:56:49 +0200
committerYves Senn <yves.senn@gmail.com>2015-08-28 15:59:37 +0200
commit35df925b475f2f9fc593c4a1caf5009e5c970b0d (patch)
tree1b892c080c2e2041d741e1345fdd54ecd8066583 /activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
parent7a27de2bb055ea35c4396ac818d20b0e5aa44ab4 (diff)
downloadrails-35df925b475f2f9fc593c4a1caf5009e5c970b0d.tar.gz
rails-35df925b475f2f9fc593c4a1caf5009e5c970b0d.tar.bz2
rails-35df925b475f2f9fc593c4a1caf5009e5c970b0d.zip
pg, `create_schema`, `drop_schema` and `rename_table` quote schema name.
Closes #21418. Previously schema names were not quoted. This leads to issues when a schema names contains a ".". Methods in `schema_statements.rb` should quote user input.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb6
1 files changed, 3 insertions, 3 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 21268b63b1..a3fc8fbc51 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
@@ -210,12 +210,12 @@ module ActiveRecord
# Creates a schema for the given schema name.
def create_schema schema_name
- execute "CREATE SCHEMA #{schema_name}"
+ execute "CREATE SCHEMA #{quote_schema_name(schema_name)}"
end
# Drops the schema for the given schema name.
def drop_schema(schema_name, options = {})
- execute "DROP SCHEMA#{' IF EXISTS' if options[:if_exists]} #{schema_name} CASCADE"
+ execute "DROP SCHEMA#{' IF EXISTS' if options[:if_exists]} #{quote_schema_name(schema_name)} CASCADE"
end
# Sets the schema search path to a string of comma-separated schema names.
@@ -376,7 +376,7 @@ module ActiveRecord
new_seq = "#{new_name}_#{pk}_seq"
idx = "#{table_name}_pkey"
new_idx = "#{new_name}_pkey"
- execute "ALTER TABLE #{quote_table_name(seq)} RENAME TO #{quote_table_name(new_seq)}"
+ execute "ALTER TABLE #{seq.quoted} RENAME TO #{quote_table_name(new_seq)}"
execute "ALTER INDEX #{quote_table_name(idx)} RENAME TO #{quote_table_name(new_idx)}"
end