lib/gratan/driver.rb in gratan-0.2.9 vs lib/gratan/driver.rb in gratan-0.3.0.beta

- old
+ new

@@ -111,9 +111,28 @@ quote_user(user, host), quote_identifier(identifier), ] update(sql) + + if (identifier || '').empty? + set_password(user, host, identifier) + end + end + + def set_password(user, host, password, options = {}) + password ||= '' + + unless options[:hash] + password = "PASSWORD('#{escape(password)}')" + end + + sql = 'SET PASSWORD FOR %s = %s' % [ + quote_user(user, host), + password, + ] + + update(sql) end def set_require(user, host, required) required ||= 'NONE'