Quote ALTER SCHEMA SET values - #70
Conversation
|
Please escape control characters such as Also, please remove or substantially shorten the explanatory comment blocks in |
|
I have addressed your feedback
Please let me know if you require further changes. |
|
Rather than extending the replacement chain one character at a time, please use the existing escaped = json.dumps(str(value), ensure_ascii=False)[1:-1].replace("'", "''")Please add regression coverage containing |
|
Done — the fallback now uses |
…e literal
update_schema built its SQL literal with a bare f"'{new_value}'", so an
apostrophe in the value ended the string early and the rest arrived as bare SQL:
001003 (42000): SQL compilation error: syntax error line 1 at position 39
unexpected 'comment'. on ALTER SCHEMA MY_DB.MY_SCHEMA SET comment = '...
Any schema comment containing an apostrophe therefore fails to apply. Only the
ALTER path is affected -- CREATE already renders through props.quote_value,
which dollar-quotes and needs no escaping. update_schema was the one branch
that hand-rolled its quoting; it now goes through quote_value too.
quote_value itself had the mirror-image gap: $$ is a safe delimiter only while
the value does not contain $$. It now falls back to a single-quoted literal
with ' and backslash doubled in that case, so a value cannot break out by
either route.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Snowflake needs escape sequences, not raw control characters, inside a single-quoted literal, so the $$ fallback regressed multiline values. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The hand-rolled replacement chain covered newline, carriage return and tab but left backspace, form feed, NUL and the rest of the C0 range raw in the single-quoted literal. json.dumps escapes the whole range using the same backslash syntax Snowflake accepts, so the fallback now only has to double apostrophes on top of it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
4c599b4 to
403ffa7
Compare
update_schemabuilds its literal by hand:so an apostrophe ends the string early and the rest arrives as bare SQL:
Any schema comment containing an apostrophe fails to apply.
CREATEis unaffected — it already renders throughprops.quote_value.update_schemawas the one branch that hand-rolled its quoting; it now usesquote_valuetoo.quote_valuehad the mirror-image gap:$$is a safe delimiter only while the value doesn't contain$$. It now falls back to a single-quoted literal with'and backslash doubled in that case.4 regression tests, all four failing against the current code.