Conversation
There was a problem hiding this comment.
Codex Review: Here are some suggestions.
Reply with @codex fix comments to fix any unresolved comments.
About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".
| let statementForParsing = statement; | ||
| let forcedBehavior: 'REPLACE' | undefined; | ||
|
|
||
| if (upper.startsWith('REPLACE')) { | ||
| forcedBehavior = 'REPLACE'; | ||
| statementForParsing = statement.replace(/^REPLACE\s+/i, 'INSERT OR REPLACE '); | ||
| } |
There was a problem hiding this comment.
[P1] Handle REPLACE statements with leading whitespace
The REPLACE → INSERT rewrite only runs when statement.replace(/^REPLACE\s+/i, …) matches the raw SQL. Because the code determines REPLACE by trimming the statement (line 94) but performs the replacement on the untrimmed string (lines 97‑103), any REPLACE statement that begins with indentation or a leading newline is left untouched and falls through to the default path. The unmodified REPLACE keyword is then mirrored to Postgres, which rejects the statement and causes the mirror queue to fail. The replacement logic should allow leading whitespace, e.g. by trimming before the regex or anchoring the regex after optional whitespace.
Useful? React with 👍 / 👎.
Summary
Testing
npm testhttps://chatgpt.com/codex/tasks/task_e_68cc931e873c8324bb9b430a6ead69ad