Skip to content

Commit 608e4e8

Browse files
Stuart Grimshawhunner
Stuart Grimshaw
authored andcommitted
Fixed SQL for databse_grant and database_user when ANSI_QUOTES Mysql option is set.
1 parent d29bc94 commit 608e4e8

File tree

1 file changed

+5
-5
lines changed
  • lib/puppet/provider/database_grant

1 file changed

+5
-5
lines changed

lib/puppet/provider/database_grant/mysql.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def row_exists?
9696
if name[:type] == :db
9797
fields << :db
9898
end
99-
not mysql([defaults_file, "mysql", '-NBe', 'SELECT "1" FROM %s WHERE %s' % [ name[:type], fields.map do |f| "%s=\"%s\"" % [f, name[f]] end.join(' AND ')]].compact).empty?
99+
not mysql([defaults_file, "mysql", '-NBe', "SELECT '1' FROM %s WHERE %s" % [ name[:type], fields.map do |f| "%s='%s'" % [f, name[f]] end.join(' AND ')]].compact).empty?
100100
end
101101

102102
def all_privs_set?
@@ -118,9 +118,9 @@ def privileges
118118

119119
case name[:type]
120120
when :user
121-
privs = mysql([defaults_file, "mysql", "-Be", 'select * from mysql.user where user="%s" and host="%s"' % [ name[:user], name[:host] ]].compact)
121+
privs = mysql([defaults_file, "mysql", "-Be", "select * from mysql.user where user='%s' and host='%s'" % [ name[:user], name[:host] ]].compact)
122122
when :db
123-
privs = mysql([defaults_file, "mysql", "-Be", 'select * from mysql.db where user="%s" and host="%s" and db="%s"' % [ name[:user], name[:host], name[:db] ]].compact)
123+
privs = mysql([defaults_file, "mysql", "-Be", "select * from mysql.db where user='%s' and host='%s' and db='%s'" % [ name[:user], name[:host], name[:db] ]].compact)
124124
end
125125

126126
if privs.match(/^$/)
@@ -149,11 +149,11 @@ def privileges=(privs)
149149
case name[:type]
150150
when :user
151151
stmt = 'update user set '
152-
where = ' where user="%s" and host="%s"' % [ name[:user], name[:host] ]
152+
where = " where user='%s' and host='%s'" % [ name[:user], name[:host] ]
153153
all_privs = user_privs
154154
when :db
155155
stmt = 'update db set '
156-
where = ' where user="%s" and host="%s" and db="%s"' % [ name[:user], name[:host], name[:db] ]
156+
where = " where user='%s' and host='%s' and db='%s'" % [ name[:user], name[:host], name[:db] ]
157157
all_privs = db_privs
158158
end
159159

0 commit comments

Comments
 (0)