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

Incorrect escaping of singlequotes in view comments #1049

Closed
lkorpalski-pgs opened this issue Jun 9, 2022 · 4 comments
Closed

Incorrect escaping of singlequotes in view comments #1049

lkorpalski-pgs opened this issue Jun 9, 2022 · 4 comments
Labels
bug Used to mark issues with provider's incorrect behavior category:resource resource:view Issue connected to the snowflake_view resource

Comments

@lkorpalski-pgs
Copy link

lkorpalski-pgs commented Jun 9, 2022

Provider Version 0.35.0
Terraform Version 1.1.2
Describe the bug

When specifying a comment in a snowflake_view resource which includes a single quote character ('), this doesn't get escaped properly, resulting in a semi-broken SQL, which is getting repeatedly replaced on each terraform run.

Expected behavior

Escape the single quote, or at least detect it as an illegal character and fail.

Code samples and commands

resource snowflake_view view {
  database = "db"
  schema   = "schema"
  name     = "view"

  comment = "comment with 'quotes' is broken"

  statement  = <<-SQL
    select * from foo;
SQL
  or_replace = false
  is_secure  = false
}

Additional context

This is a bug of the annoying type, as even with the incorrect SQL structure, the view is working, just tf produces additional output logs and recreates the resource repeatedly.

@lkorpalski-pgs lkorpalski-pgs added the bug Used to mark issues with provider's incorrect behavior label Jun 9, 2022
@monti-python
Copy link

monti-python commented Jan 24, 2024

This is still happening in version 0.83.0 and with different types of resources. We are unable to create a role with single quotes within the comment attribute, e.g:

resource "snowflake_role" "mkt_prod" {
  name = "MKT_PROD"
  comment = "Role that grants access on the 'MKT' schema in environment 'PROD'"
}

This fails with the error:

│ Error: 001003 (42000): SQL compilation error:
│ syntax error line 1 at position 125 unexpected '' schema in environment ''.

@sfc-gh-jcieslak
Copy link
Collaborator

sfc-gh-jcieslak commented Jan 31, 2024

Hey @lkorpalski-pgs
It should be the same case as in #2411. Lucky there's an open pr (#2448) that uses new SDK in view and materialized view, so after we merge and release it, the error shouldn't appear anymore.

@sfc-gh-jcieslak sfc-gh-jcieslak added category:resource resource:view Issue connected to the snowflake_view resource labels May 20, 2024
@sfc-gh-jcieslak
Copy link
Collaborator

Hey @lkorpalski-pgs 👋
Yesterday, we released a new provider version (v0.95.0) that introduces a lot of changes (also the previously mentioned pr should resolve this issue). Please upgrade using the migration guide. Closing this one, please create another issue if the problem still persists in the newer versions.

@lkorpalski-pgs
Copy link
Author

Unfortunately I can't confirm the fix myself, as I got moved to another project since then. Thank you for the notice though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to mark issues with provider's incorrect behavior category:resource resource:view Issue connected to the snowflake_view resource
Projects
None yet
Development

No branches or pull requests

3 participants