Skip to content

Commit 2de076e

Browse files
committed
Made a test case on working with privileges on columns that are called such as FIRST, ID, KEY, LAST, ORDER, etc
1 parent 5be87ac commit 2de076e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

mysql/resource_grant_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,15 @@ func TestAccGrantComplex(t *testing.T) {
189189
resource.TestCheckResourceAttr("mysql_grant.test", "table", "tbl"),
190190
),
191191
},
192+
{
193+
Config: testAccGrantConfigWithPrivs(dbName, "\"SELECT (`id`,`key`,`order`,`first`,`last`)\"", false),
194+
Check: resource.ComposeTestCheckFunc(
195+
resource.TestCheckResourceAttr("mysql_grant.test", "user", fmt.Sprintf("jdoe-%s", dbName)),
196+
resource.TestCheckResourceAttr("mysql_grant.test", "host", "example.com"),
197+
resource.TestCheckResourceAttr("mysql_grant.test", "database", dbName),
198+
resource.TestCheckResourceAttr("mysql_grant.test", "table", "tbl"),
199+
),
200+
},
192201
{
193202
Config: testAccGrantConfigWithPrivs(dbName, `"DROP", "SELECT (c1)", "INSERT(c3, c4)", "REFERENCES(c5)"`, false),
194203
Check: resource.ComposeTestCheckFunc(
@@ -484,7 +493,7 @@ func prepareTable(dbname string, tableName string) resource.TestCheckFunc {
484493
if err != nil {
485494
return err
486495
}
487-
if _, err := db.Exec(fmt.Sprintf("CREATE TABLE `%s`.`%s`(c1 INT, c2 INT, c3 INT,c4 INT,c5 INT);", dbname, tableName)); err != nil {
496+
if _, err := db.Exec(fmt.Sprintf("CREATE TABLE `%s`.`%s`(c1 INT, c2 INT, c3 INT, c4 INT, c5 INT, `id` INT, `key` INT, `order` INT, `type` INT, `status` INT, `created` INT, `updated` INT, `user` INT, `name` INT, `group` INT, `value` INT, `index` INT, `source` INT, `date` INT, `state` INT, `last` INT, `first` INT, `email` INT, `phone` INT, `amount` INT, `reference` INT, `reason` INT, `hash` INT, `team` INT, `case` INT, `uid` INT, `path` INT);", dbname, tableName)); err != nil {
488497
return fmt.Errorf("error reading grant: %s", err)
489498
}
490499
return nil

0 commit comments

Comments
 (0)