diff --git a/pkg/datasources/row_access_policies.go b/pkg/datasources/row_access_policies.go index e16d8069ae..7de84d4811 100644 --- a/pkg/datasources/row_access_policies.go +++ b/pkg/datasources/row_access_policies.go @@ -3,9 +3,9 @@ package datasources import ( "context" "database/sql" - "fmt" "log" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/helpers" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -85,6 +85,6 @@ func ReadRowAccessPolicies(d *schema.ResourceData, meta interface{}) error { } } - d.SetId(fmt.Sprintf(`%v|%v`, databaseName, schemaName)) + d.SetId(helpers.EncodeSnowflakeID(databaseName, schemaName)) return d.Set("row_access_policies", rowAccessPolicies) } diff --git a/pkg/resources/row_access_policy.go b/pkg/resources/row_access_policy.go index 8750bea307..07b3a264c3 100644 --- a/pkg/resources/row_access_policy.go +++ b/pkg/resources/row_access_policy.go @@ -82,10 +82,7 @@ func CreateRowAccessPolicy(d *schema.ResourceData, meta interface{}) error { args := make([]sdk.CreateRowAccessPolicyArgsRequest, 0) for k, v := range signature { - dataType, err := sdk.ToDataType(v.(string)) - if err != nil { - return err - } + dataType := sdk.DataType(v.(string)) args = append(args, *sdk.NewCreateRowAccessPolicyArgsRequest(k, dataType)) } diff --git a/pkg/sdk/testint/row_access_policies_gen_integration_test.go b/pkg/sdk/testint/row_access_policies_gen_integration_test.go index d85bca82a6..ce17cf3b0e 100644 --- a/pkg/sdk/testint/row_access_policies_gen_integration_test.go +++ b/pkg/sdk/testint/row_access_policies_gen_integration_test.go @@ -291,6 +291,21 @@ func TestInt_RowAccessPolicies(t *testing.T) { assertRowAccessPolicyDescription(t, returnedRowAccessPolicyDescription, rowAccessPolicy.ID(), fmt.Sprintf("(%s %s)", strings.ToUpper(argName), sdk.DataTypeTimestampNTZ), body) }) + t.Run("describe row access policy: with data type normalization", func(t *testing.T) { + argName := random.AlphaN(5) + argType := sdk.DataType("VARCHAR(200)") + args := sdk.NewCreateRowAccessPolicyArgsRequest(argName, argType) + body := "true" + + request := createRowAccessPolicyRequest(t, []sdk.CreateRowAccessPolicyArgsRequest{*args}, body) + rowAccessPolicy := createRowAccessPolicyWithRequest(t, request) + + returnedRowAccessPolicyDescription, err := client.RowAccessPolicies.Describe(ctx, rowAccessPolicy.ID()) + require.NoError(t, err) + + assertRowAccessPolicyDescription(t, returnedRowAccessPolicyDescription, rowAccessPolicy.ID(), fmt.Sprintf("(%s %s)", strings.ToUpper(argName), sdk.DataTypeVARCHAR), body) + }) + t.Run("describe row access policy: non-existing", func(t *testing.T) { id := sdk.NewSchemaObjectIdentifier(testDb(t).Name, testSchema(t).Name, "does_not_exist")