Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_synapse_sql_pool Allow UTF-8 characters in SQL pool name #13289

Merged
merged 1 commit into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions internal/services/synapse/synapse_sql_pool_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ func TestAccSynapseSqlPool_basic(t *testing.T) {
})
}

func TestAccSynapseSqlPool_utf8(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_synapse_sql_pool", "test")
r := SynapseSqlPoolResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.utf8(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccSynapseSqlPool_requiresImport(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_synapse_sql_pool", "test")
r := SynapseSqlPoolResource{}
Expand Down Expand Up @@ -124,6 +139,24 @@ resource "azurerm_synapse_sql_pool" "test" {
`, template, data.RandomString)
}

func (r SynapseSqlPoolResource) utf8(data acceptance.TestData) string {
template := r.template(data)
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

%s

resource "azurerm_synapse_sql_pool" "test" {
name = "販売管理"
synapse_workspace_id = azurerm_synapse_workspace.test.id
sku_name = "DW100c"
create_mode = "Default"
}
`, template)
}

func (r SynapseSqlPoolResource) requiresImport(data acceptance.TestData) string {
config := r.basic(data)
return fmt.Sprintf(`
Expand Down
8 changes: 4 additions & 4 deletions internal/services/synapse/validate/sql_pool_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ func SqlPoolName(i interface{}, k string) (warnings []string, errors []error) {
}

// The name attribute rules are :
// 1. can contain only letters, numbers and underscore.
// 2. The value must be between 1 and 15 characters long

if !regexp.MustCompile(`^[a-zA-Z_\d]{1,15}$`).MatchString(v) {
// 1. can't contain '<,>,*,%,&,:,\,/,?,@,-' or control characters
// 2. can't end with '.' or ' '
// 3. The value must be between 1 and 60 characters long
if !regexp.MustCompile(`^[^<>*%&:\\\/?@-]{0,59}[^\s.<>*%&:\\\/?@-]$`).MatchString(v) {
errors = append(errors, fmt.Errorf("%s can contain only letters, numbers or underscore, The value must be between 1 and 15 characters long", k))
return
}
Expand Down
23 changes: 19 additions & 4 deletions internal/services/synapse/validate/sql_pool_name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,34 @@ func TestSqlPoolName(t *testing.T) {
input: "aBc_123",
expected: true,
},
{
// UTF-8
input: "販売管理",
expected: true,
},
{
// can't contain hyphen
input: "ab-c",
expected: false,
},
{
// 15 chars
input: "abcdefghijklmno",
// can't end with .
input: "abc.",
expected: false,
},
{
// can't end with space
input: "abc ",
expected: false,
},
{
// 60 chars
input: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefgh",
expected: true,
},
{
// 16 chars
input: "abcdefghijklmnop",
// 61 chars
input: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi",
expected: false,
},
}
Expand Down