From 81416af45d02a1270229c77a9ea3d78123e1a6f4 Mon Sep 17 00:00:00 2001 From: kt Date: Wed, 6 Dec 2023 19:00:10 -0800 Subject: [PATCH] azurerm_mssql_database|azurerm_mssql_managed_database - do not send long rendition values in payload unless set (#24124) --- .../mssql/helper/sql_retention_policies.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/services/mssql/helper/sql_retention_policies.go b/internal/services/mssql/helper/sql_retention_policies.go index 901bd3768954..f42ac97e89c8 100644 --- a/internal/services/mssql/helper/sql_retention_policies.go +++ b/internal/services/mssql/helper/sql_retention_policies.go @@ -113,20 +113,20 @@ func ExpandLongTermRetentionPolicy(input []interface{}) *longtermretentionpolici WeekOfYear: pointer.To(int64(1)), } - if v, ok := policy["weekly_retention"]; ok { - output.WeeklyRetention = pointer.To(v.(string)) + if v, ok := policy["weekly_retention"].(string); ok && v != "" { + output.WeeklyRetention = pointer.To(v) } - if v, ok := policy["monthly_retention"]; ok { - output.MonthlyRetention = pointer.To(v.(string)) + if v, ok := policy["monthly_retention"].(string); ok && v != "" { + output.MonthlyRetention = pointer.To(v) } - if v, ok := policy["yearly_retention"]; ok { - output.YearlyRetention = pointer.To(v.(string)) + if v, ok := policy["yearly_retention"].(string); ok && v != "" { + output.YearlyRetention = pointer.To(v) } - if v, ok := policy["week_of_year"]; ok { - output.WeekOfYear = pointer.To(int64(v.(int))) + if v, ok := policy["week_of_year"].(int); ok && v != 0 { + output.WeekOfYear = pointer.To(int64(v)) } return pointer.To(output)