diff --git a/digitalocean/database/resource_database_mysql_config.go b/digitalocean/database/resource_database_mysql_config.go index 4e3391600..95eff5464 100644 --- a/digitalocean/database/resource_database_mysql_config.go +++ b/digitalocean/database/resource_database_mysql_config.go @@ -242,7 +242,7 @@ func updateMySQLConfig(ctx context.Context, d *schema.ResourceData, client *godo opts.SQLMode = godo.PtrTo(v.(string)) } - if v, ok := d.GetOk("sql_require_primary_key"); ok { + if v, ok := d.GetOkExists("sql_require_primary_key"); ok { opts.SQLRequirePrimaryKey = godo.PtrTo(v.(bool)) } @@ -270,11 +270,11 @@ func updateMySQLConfig(ctx context.Context, d *schema.ResourceData, client *godo opts.InnodbFtServerStopwordTable = godo.PtrTo(v.(string)) } - if v, ok := d.GetOk("innodb_print_all_deadlocks"); ok { + if v, ok := d.GetOkExists("innodb_print_all_deadlocks"); ok { opts.InnodbPrintAllDeadlocks = godo.PtrTo(v.(bool)) } - if v, ok := d.GetOk("innodb_rollback_on_timeout"); ok { + if v, ok := d.GetOkExists("innodb_rollback_on_timeout"); ok { opts.InnodbRollbackOnTimeout = godo.PtrTo(v.(bool)) } diff --git a/digitalocean/database/resource_database_mysql_config_test.go b/digitalocean/database/resource_database_mysql_config_test.go index 4fda6773e..2225d65c8 100644 --- a/digitalocean/database/resource_database_mysql_config_test.go +++ b/digitalocean/database/resource_database_mysql_config_test.go @@ -18,17 +18,19 @@ func TestAccDigitalOceanDatabaseMySQLConfig_Basic(t *testing.T) { CheckDestroy: testAccCheckDigitalOceanDatabaseClusterDestroy, Steps: []resource.TestStep{ { - Config: fmt.Sprintf(testAccCheckDigitalOceanDatabaseMySQLConfigConfigBasic, dbConfig, 10, "UTC"), + Config: fmt.Sprintf(testAccCheckDigitalOceanDatabaseMySQLConfigConfigBasic, dbConfig, 10, "UTC", false), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("digitalocean_database_mysql_config.foobar", "connect_timeout", "10"), resource.TestCheckResourceAttr("digitalocean_database_mysql_config.foobar", "default_time_zone", "UTC"), + resource.TestCheckResourceAttr("digitalocean_database_mysql_config.foobar", "sql_require_primary_key", "false"), ), }, { - Config: fmt.Sprintf(testAccCheckDigitalOceanDatabaseMySQLConfigConfigBasic, dbConfig, 15, "SYSTEM"), + Config: fmt.Sprintf(testAccCheckDigitalOceanDatabaseMySQLConfigConfigBasic, dbConfig, 15, "SYSTEM", false), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("digitalocean_database_mysql_config.foobar", "connect_timeout", "15"), resource.TestCheckResourceAttr("digitalocean_database_mysql_config.foobar", "default_time_zone", "SYSTEM"), + resource.TestCheckResourceAttr("digitalocean_database_mysql_config.foobar", "sql_require_primary_key", "false"), ), }, }, @@ -39,7 +41,8 @@ const testAccCheckDigitalOceanDatabaseMySQLConfigConfigBasic = ` %s resource "digitalocean_database_mysql_config" "foobar" { - cluster_id = digitalocean_database_cluster.foobar.id - connect_timeout = %d - default_time_zone = "%s" + cluster_id = digitalocean_database_cluster.foobar.id + connect_timeout = %d + default_time_zone = "%s" + sql_require_primary_key = "%t" }`