Skip to content

Commit

Permalink
Fix of actual read of grant roles
Browse files Browse the repository at this point in the history
  • Loading branch information
petoju committed Feb 24, 2021
1 parent 82fc6fb commit 6240d06
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mysql/resource_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ func ReadGrant(d *schema.ResourceData, meta interface{}) error {
d.SetId("")
return nil
}
// TODO: read of grants of roles is not fully supported. Add the support.
database := d.Get("database").(string)
table := d.Get("table").(string)

Expand All @@ -263,6 +262,9 @@ func ReadGrant(d *schema.ResourceData, meta interface{}) error {
for _, grant := range grants {
if grant.Database == database && grant.Table == table {
privileges = makePrivs(setToArray(d.Get("privileges")), grant.Privileges)
}
// Granting role is just role without DB & table.
if grant.Database == "" && grant.Table == "" {
roles = grant.Roles
}

Expand Down Expand Up @@ -488,7 +490,6 @@ func showGrants(db *sql.DB, user string) ([]*MySQLGrant, error) {
var rawGrant string

err := rows.Scan(&rawGrant)

if err != nil {
return nil, err
}
Expand Down

0 comments on commit 6240d06

Please sign in to comment.