From 3d500598b04c03534605542df782b0379ebeb2cb Mon Sep 17 00:00:00 2001 From: kt Date: Tue, 5 Dec 2023 12:55:45 -0800 Subject: [PATCH] azurerm_mssql_database|azurerm_mssql_managed_database - do not send log rentetion values in payload unles set --- .../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)