You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A bracket-quoted identifier containing ]] round-trips to SQL that fails to reparse #2409
input: SELECT [a]]b]
printed: SELECT [a]b]
reparsed: Err(ParserError("Expected: end of statement, found: ] at Line: 1, Column: 12"))
[a]]b] is a bracket-quoted identifier whose value is a]b (the tokenizer folds the doubled ]] into a literal ]). Displaying the parsed AST back to SQL writes [a]b] instead, and that string does not parse as the same identifier: it parses as a followed by leftover tokens ]b].
Tested on sqlparser 0.62.0.
BTW, this bug was found using hegel. Happy to contribute the tests if you're interested.
Confirmed on main. One wrinkle worth flagging: the fix can't just double ] unconditionally, because Redshift also parses nested quoted identifiers like ["a]b"] where the value is stored as the complete double-quoted string "a]b" and the inner ] is literal (doubling it would break that round-trip). The AST doesn't distinguish the two forms, so I double ] only when the value isn't a complete "..." string. Opened #2418.
Activity
hdimer commentedon Jul 30, 2026
Confirmed on main. One wrinkle worth flagging: the fix can't just double
]unconditionally, because Redshift also parses nested quoted identifiers like["a]b"]where the value is stored as the complete double-quoted string"a]b"and the inner]is literal (doubling it would break that round-trip). The AST doesn't distinguish the two forms, so I double]only when the value isn't a complete"..."string. Opened #2418.Escape closing brackets in bracket-quoted identifiers