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

[Bug]: snowflake_table_constraint wrong default value #3382

Open
1 task
martinw-intersport opened this issue Feb 5, 2025 · 1 comment
Open
1 task

[Bug]: snowflake_table_constraint wrong default value #3382

martinw-intersport opened this issue Feb 5, 2025 · 1 comment
Labels
feature-request Used to mark issues with provider's missing functionalities general-usage General help/usage questions resource:table_constraint Issue connected to the snowflake_table_constraint resource resource:table Issue connected to the snowflake_table resource

Comments

@martinw-intersport
Copy link

martinw-intersport commented Feb 5, 2025

Terraform CLI Version

1.10.5

Terraform Provider Version

1.0.2

Company Name

No response

Terraform Configuration

# Add foreign key constraints
resource "snowflake_table_constraint" "constraint" {
  name     = "FKEY"
  type     = "FOREIGN KEY"
  enforced = false
  table_id = snowflake_table.b.fully_qualified_name
  columns  = ["ID"]
  foreign_key_properties {
    references {
      table_id = snowflake_table.a.fully_qualified_name
      columns  = ["ID"]
    }
  }
}

Category

category:resource

Object type(s)

No response

Expected Behavior

According to https://docs.snowflake.com/en/sql-reference/sql/create-table-constraint#constraint-properties, the default value are NOT DEFERRABLE and DISABLE, so deferrable = false and enable= false

Actual Behavior

current terraform plan

+ resource "snowflake_table_constraint" "constraint" {
       + columns    = [
           + "ID",
         ]
       + deferrable = true  <-----wrong
       + enable     = true  <-----wrong
       + enforced   = false
       + id         = (known after apply)
       + initially  = "DEFERRED"
       + name       = "FKEY"
       + rely       = true
       + table_id   = (known after apply)
       + type       = "FOREIGN KEY"
       + validate   = false
       + foreign_key_properties {
           + match     = "FULL"
           + on_delete = "NO ACTION"
           + on_update = "NO ACTION"
           + references {
               + columns  = [
                   + "ID",
                 ]
               + table_id = "..."
             }
         }
     }

Steps to Reproduce

  1. Copy Terraform Configuration
  2. Run terraform plan
  3. Check enable and deferrable value

How much impact is this issue causing?

Low

Logs

No response

Additional Information

No response

Would you like to implement a fix?

  • Yeah, I'll take it 😎
@martinw-intersport martinw-intersport added the bug Used to mark issues with provider's incorrect behavior label Feb 5, 2025
@sfc-gh-asawicki sfc-gh-asawicki added general-usage General help/usage questions feature-request Used to mark issues with provider's missing functionalities resource:table Issue connected to the snowflake_table resource resource:table_constraint Issue connected to the snowflake_table_constraint resource and removed bug Used to mark issues with provider's incorrect behavior labels Feb 5, 2025
@sfc-gh-asawicki
Copy link
Collaborator

Hey @martinw-intersport. Thanks for reaching out to us.

The default values for older versions of the provided were baked in the provider. We went away from it (check https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/v1-preparations/CHANGES_BEFORE_V1.md#default-values). Sadly, the generated resource docs do not show the tf default, I will make sure we are adding the defaults (if present) in the newest provider versions docs.

As for the defaults in this resource - we will rework it after GA and fallback correctly to Snowflake defaults.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Used to mark issues with provider's missing functionalities general-usage General help/usage questions resource:table_constraint Issue connected to the snowflake_table_constraint resource resource:table Issue connected to the snowflake_table resource
Projects
None yet
Development

No branches or pull requests

2 participants