diff --git a/azurerm/helpers/validate/database.go b/azurerm/helpers/validate/database.go index bda83f52b22a..d79aa3abb502 100644 --- a/azurerm/helpers/validate/database.go +++ b/azurerm/helpers/validate/database.go @@ -12,10 +12,10 @@ func DatabaseCollation(i interface{}, k string) (warnings []string, errors []err return } - matched, _ := regexp.MatchString(`^[A-Za-z0-9_. ]+$`, v) + matched, _ := regexp.MatchString(`^[-A-Za-z0-9_. ]+$`, v) if !matched { - errors = append(errors, fmt.Errorf("%s contains invalid characters, only underscores are supported, got %s", k, v)) + errors = append(errors, fmt.Errorf("%s contains invalid characters, only alphanumeric, underscore, space or hyphen characters are supported, got %s", k, v)) return } diff --git a/azurerm/helpers/validate/database_test.go b/azurerm/helpers/validate/database_test.go index 773ee5a203d0..01e748cc5f94 100644 --- a/azurerm/helpers/validate/database_test.go +++ b/azurerm/helpers/validate/database_test.go @@ -8,9 +8,13 @@ func TestDatabaseCollation(t *testing.T) { Errors int }{ { - Value: "en-US", + Value: "en@US", Errors: 1, }, + { + Value: "en-US", + Errors: 0, + }, { Value: "en_US", Errors: 0, diff --git a/azurerm/resource_arm_postgresql_database.go b/azurerm/resource_arm_postgresql_database.go index c915f8a5afc6..12e60d6a0693 100644 --- a/azurerm/resource_arm_postgresql_database.go +++ b/azurerm/resource_arm_postgresql_database.go @@ -3,7 +3,6 @@ package azurerm import ( "fmt" "log" - "strings" "time" "github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2017-12-01/postgresql" @@ -152,11 +151,7 @@ func resourceArmPostgreSQLDatabaseRead(d *schema.ResourceData, meta interface{}) if props := resp.DatabaseProperties; props != nil { d.Set("charset", props.Charset) - - if collation := props.Collation; collation != nil { - v := strings.Replace(*collation, "-", "_", -1) - d.Set("collation", v) - } + d.Set("collation", props.Collation) } return nil