:show_db, :super, :create_tmp_table, :lock_tables, :execute,
:repl_slave, :repl_client, :create_view, :show_view, :create_routine,
:alter_routine, :create_user, :event, :trigger, :create_tablespace
- ]
+ ].freeze
DATABASE_PRIVILEGES = [
:select, :insert, :update, :delete, :create, :drop, :grant,
:references, :index, :alter, :create_tmp_table, :lock_tables,
:create_view, :show_view, :create_routine, :alter_routine,
:execute, :event, :trigger
- ]
+ ].freeze
def execute(options)
# Create argument array
end
query("SELECT * FROM db").each do |record|
- if database = @databases[record[:db]]
- user = "'#{record[:user]}'@'#{record[:host]}'"
+ database = @databases[record[:db]]
- database[:permissions][user] = DATABASE_PRIVILEGES.each_with_object([]) do |privilege, privileges|
- privileges << privilege if record["#{privilege}_priv".to_sym] == "Y"
- end
+ next unless database
+
+ user = "'#{record[:user]}'@'#{record[:host]}'"
+
+ database[:permissions][user] = DATABASE_PRIVILEGES.each_with_object([]) do |privilege, privileges|
+ privileges << privilege if record["#{privilege}_priv".to_sym] == "Y"
end
end