Skip to content

Commit

Permalink
Fix ReadDatabase when collation empty
Browse files Browse the repository at this point in the history
When collation is empty from `SHOW CREATE DATABASE` command, the `if`
statement bypasses setting the character set and collation on the
resource data.
  • Loading branch information
Mitchell Cowie committed May 22, 2018
1 parent 7234a32 commit 8a12122
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions mysql/resource_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ func ReadDatabase(d *schema.ResourceData, meta interface{}) error {
// the charset, so if we don't have a collation we need to go
// hunt for the default.
stmtSQL := "SHOW COLLATION WHERE `Charset` = ? AND `Default` = 'Yes'"
var defaultCollation string
var empty interface{}
err := db.QueryRow(stmtSQL, defaultCharset).Scan(&defaultCollation, &empty, &empty, &empty, &empty, &empty)
if err != nil {
Expand All @@ -115,7 +114,6 @@ func ReadDatabase(d *schema.ResourceData, meta interface{}) error {
}
return fmt.Errorf("Error getting default charset: %s, %s", err, defaultCharset)
}
return err
}

d.Set("default_character_set", defaultCharset)
Expand Down

0 comments on commit 8a12122

Please sign in to comment.