Repository navigation
fix(cli): concatenateQueries comment issues - #2414
Conversation
| } else if (char === "/" && next === "*") { | ||
| const end = statement.indexOf("*/", i + 2); | ||
| i = end === -1 ? statement.length : end + 2; | ||
| } else if (char === "'" || char === '"' || char === "`") { |
There was a problem hiding this comment.
In GoogleSQL raw strings (r'...' or r"..."), a trailing backslash before the closing quote (like r'foo') does not escape the quote, so statement[i] === "\" will skip the closing quote. Worth only treating \ as an escape when the string is not preceded by r or R?
There was a problem hiding this comment.
Good point - I made this fix in #2408, but it makes more sense to put it here
| return codeEnd; | ||
| } | ||
|
|
||
| function formatStatement(statement: string, isLast: boolean, modifier?: (mod: string) => string) { |
There was a problem hiding this comment.
isLast is based on processed.length - 1, so if the last statement is comment-only (like ["SELECT 1", "-- comment"]), SELECT 1 gets isLast = false and has a semicolon added even though it is the last statement with code. Should isLast be computed from the last statement where codeEndIndex(statement) > 0?
mbiernacik
left a comment
There was a problem hiding this comment.
nit: The PR description lists two fixes (-- inside strings and # comments). The change also fixes multi-line trailing comments and trailing block comments containing --. It might be worth mentioning those too and linking #2413, since that PR depends on this fix.
Fixes two errors with the way concatenateQueries terminates sql statements with semicolons: