Azure / azure-sdk-for-go

This repository is for active development of the Azure SDK for Go. For consumers of the SDK we recommend visiting our public developer docs at:
https://docs.microsoft.com/azure/developer/go/
MIT License
1.63k stars 836 forks source link

PostgreSQL returns malformed collation #1862

Closed WodansSon closed 6 years ago

WodansSon commented 6 years ago

Azure-sdk-for-go Version

{
  "version": "v16.2.1",
  "versionExact": "v16.2.1"
}

Expected Behavior

The SDK should be returning a valid collation (e.g. en_US).

Actual Behavior

The SDK returns a malformed collation (e.g. en-US). The PostgreSQL resource is created by sending a valid collation (en_US), however when you read to object after creation the collation comes back malfored (en-US).

Steps to Reproduce

  1. Using the Azure Portal create a Cloud Shell instance.
  2. Create a directory called repro
  3. Navigate to the new directory (cd repro)
  4. Using nano create a file called repro.tf by copying the below Terraform HCL for PostgreSQL Resource code into the Cloud Shell session and save the file.
  5. In Cloud Shell terminal prompt type terraform init
  6. In Cloud Shell terminal prompt type terraform plan
  7. In Cloud Shell terminal prompt type terraform apply
  8. Wait for the resources to be provisioned into Azure.
  9. In Cloud Shell terminal prompt type terraform plan, here you will see the issue. Terraform will see a change needs to be made because the SDK is returning English-United States.1252 instead of English_United States.1252 with the following output:
Terraform will perform the following actions:

-/+ module.pgsql-artifactory.azurerm_postgresql_database.pgsql_db (new resource required)
      id:                             "/subscriptions/ID" => <computed> (forces new resource)
      charset:                        "UTF8" => "UTF8"
      collation:                      "English-United States.1252" => "English_United States.1252" (forces new resource)
      name:                           "dbname" => "dbname"
      resource_group_name:"rgname" => "rgname"
      server_name:                "srvname" => "srvname"

Plan: 1 to add, 0 to change, 1 to destroy.

------------------------------------------------------------------------

Terraform HCL for PostgreSQL Resource:

resource "azurerm_resource_group" "test" {
  name = "PostgreRepoRG"
  location = "west europe"
}

resource "azurerm_postgresql_server" "test" {
  name                = "postgresqlserver"
  location            = "${azurerm_resource_group.test.location}"
  resource_group_name = "${azurerm_resource_group.test.name}"

  sku {
    name     = "B_Gen4_2"
    capacity = 2
    tier     = "Basic"
    family   = "Gen4"
  }

  storage_profile {
    storage_mb = 51200
    backup_retention_days = 7
    geo_redundant_backup = "Disabled"
  }

  administrator_login          = "acctestun"
  administrator_login_password = "H@Sh1CoR3!"
  version                      = "9.6"
  ssl_enforcement              = "Enabled"
}

resource "azurerm_postgresql_database" "test" {
  name                = "postgresqldatabase"
  resource_group_name = "${azurerm_resource_group.test.name}"
  server_name         = "${azurerm_postgresql_server.test.name}"
  charset             = "UTF8"
  collation           = "English_United States.1252"
}

References

Terraform Issue #396 Terraform Issue #760

joshgav commented 6 years ago

Looks like this has been fixed in Terraform (https://github.com/terraform-providers/terraform-provider-azurerm/issues/760), but I will share this feedback with the Postgres team.