diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2017-04-20 18:08:08 -0400 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2017-04-20 18:08:08 -0400 |
commit | 972df059bbedfe60d29caa8a561f5aff76883e63 (patch) | |
tree | 60d9000e2709e688250abef2ed4e0460a268c0bf /activerecord | |
parent | e88636f733ad81c10dffde2e084e77034bc920fe (diff) | |
parent | 2d699e24ff10158c0831cf6b7f5e5b12ac41903a (diff) | |
download | rails-972df059bbedfe60d29caa8a561f5aff76883e63.tar.gz rails-972df059bbedfe60d29caa8a561f5aff76883e63.tar.bz2 rails-972df059bbedfe60d29caa8a561f5aff76883e63.zip |
Merge pull request #28681 from runephilosof/fix-mysql-grant
Fix quoting in db:create grant all statement.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG.md | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/tasks/mysql_database_tasks.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/tasks/mysql_rake_test.rb | 2 |
3 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index f0cfd0469e..a229b4eaa2 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,7 @@ +* Quote database name in db:create grant statement (when database_user does not have access to create the database). + + *Rune Philosof* + * Raise error `UnknownMigrationVersionError` on the movement of migrations when the current migration does not exist. diff --git a/activerecord/lib/active_record/tasks/mysql_database_tasks.rb b/activerecord/lib/active_record/tasks/mysql_database_tasks.rb index 920830b9cf..c05f0a8fbb 100644 --- a/activerecord/lib/active_record/tasks/mysql_database_tasks.rb +++ b/activerecord/lib/active_record/tasks/mysql_database_tasks.rb @@ -104,7 +104,7 @@ module ActiveRecord def grant_statement <<-SQL -GRANT ALL PRIVILEGES ON #{configuration['database']}.* +GRANT ALL PRIVILEGES ON `#{configuration['database']}`.* TO '#{configuration['username']}'@'localhost' IDENTIFIED BY '#{configuration['password']}' WITH GRANT OPTION; SQL diff --git a/activerecord/test/cases/tasks/mysql_rake_test.rb b/activerecord/test/cases/tasks/mysql_rake_test.rb index f30e0958c3..b85d303a91 100644 --- a/activerecord/test/cases/tasks/mysql_rake_test.rb +++ b/activerecord/test/cases/tasks/mysql_rake_test.rb @@ -167,7 +167,7 @@ if current_adapter?(:Mysql2Adapter) def assert_permissions_granted_for(db_user) db_name = @configuration["database"] db_password = @configuration["password"] - @connection.expects(:execute).with("GRANT ALL PRIVILEGES ON #{db_name}.* TO '#{db_user}'@'localhost' IDENTIFIED BY '#{db_password}' WITH GRANT OPTION;") + @connection.expects(:execute).with("GRANT ALL PRIVILEGES ON `#{db_name}`.* TO '#{db_user}'@'localhost' IDENTIFIED BY '#{db_password}' WITH GRANT OPTION;") end end |