Package dev.frostlake.executor
Class SqlStringLiterals
java.lang.Object
dev.frostlake.executor.SqlStringLiterals
The single, canonical decode for a single-quoted SQL string literal — the one place that turns a
STRING_LITERAL token (or its already-stripped inner text) into the value it denotes.
Snowflake recognises two escape mechanisms inside a '…' literal: doubling a quote
('' → ') and backslash escapes (\' → ',
\\ → \, \n/\t/\r → the control character). Any other
backslash sequence keeps the backslash verbatim. Because \' is a real escape, the lexer rule
for STRING_LITERAL treats backslash as always starting an escape, so this decoder must agree
with it — otherwise a stored procedure/function body (decoded once at CREATE, re-parsed at CALL) or any
other doubly-handled literal drifts out of alignment. Every string-literal decode site delegates here so
the behaviour is identical whether the literal appears in an expression, a DDL option, a COPY clause, a
column default, or a routine body.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringDecode a wholeSTRING_LITERALtoken, i.e. the text including its surrounding single quotes.static StringdecodeContent(String content) Decode the inner text of a string literal (surrounding quotes already stripped by the caller).static StringRender text as a single-quoted SQL string literal that decodes back to exactlytext— the inverse ofdecode(java.lang.String).
-
Method Details
-
decode
Decode a wholeSTRING_LITERALtoken, i.e. the text including its surrounding single quotes. -
encode
Render text as a single-quoted SQL string literal that decodes back to exactlytext— the inverse ofdecode(java.lang.String). In this dialect a backslash always escapes (see the lexer), so every backslash must be doubled BEFORE quote-doubling; escaping quotes alone corrupted any substituted value that itself contained escape sequences (a VARIANT whose JSON held"{\"k\":1}"reached PARSE_JSON with bare inner quotes — "Invalid JSON"). -
decodeContent
Decode the inner text of a string literal (surrounding quotes already stripped by the caller).
-