mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix quoting in db:create grant all statement.
The database name used in the test would have actually shown this if it had tried to execute on a real Mysql instead of being stubbed out (dashes in database names needs quotes).
This commit is contained in:
parent
fd097cff79
commit
2d699e24ff
3 changed files with 6 additions and 2 deletions
|
@ -1 +1,5 @@
|
||||||
|
* Quote database name in db:create grant statement (when database_user does not have access to create the database).
|
||||||
|
|
||||||
|
*Rune Philosof*
|
||||||
|
|
||||||
Please check [5-1-stable](https://github.com/rails/rails/blob/5-1-stable/activerecord/CHANGELOG.md) for previous changes.
|
Please check [5-1-stable](https://github.com/rails/rails/blob/5-1-stable/activerecord/CHANGELOG.md) for previous changes.
|
||||||
|
|
|
@ -104,7 +104,7 @@ module ActiveRecord
|
||||||
|
|
||||||
def grant_statement
|
def grant_statement
|
||||||
<<-SQL
|
<<-SQL
|
||||||
GRANT ALL PRIVILEGES ON #{configuration['database']}.*
|
GRANT ALL PRIVILEGES ON `#{configuration['database']}`.*
|
||||||
TO '#{configuration['username']}'@'localhost'
|
TO '#{configuration['username']}'@'localhost'
|
||||||
IDENTIFIED BY '#{configuration['password']}' WITH GRANT OPTION;
|
IDENTIFIED BY '#{configuration['password']}' WITH GRANT OPTION;
|
||||||
SQL
|
SQL
|
||||||
|
|
|
@ -167,7 +167,7 @@ if current_adapter?(:Mysql2Adapter)
|
||||||
def assert_permissions_granted_for(db_user)
|
def assert_permissions_granted_for(db_user)
|
||||||
db_name = @configuration["database"]
|
db_name = @configuration["database"]
|
||||||
db_password = @configuration["password"]
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue