Skip to content

Add SQLite write translation helper and tests#1

Open
stritt wants to merge 1 commit intomainfrom
codex/add-translatesqlitewritetopostgres-helper
Open

Add SQLite write translation helper and tests#1
stritt wants to merge 1 commit intomainfrom
codex/add-translatesqlitewritetopostgres-helper

Conversation

@stritt
Copy link
Copy Markdown
Contributor

@stritt stritt commented Sep 18, 2025

Summary

  • add a translator that normalizes SQLite write statements and rewrites common SQLite-only patterns for Postgres
  • invoke the translator during mirroring so unsupported statements are skipped instead of retried endlessly
  • cover INSERT OR IGNORE, REPLACE, and DELETE ... LIMIT mirroring along with PRAGMA skips in unit tests

Testing

  • npm test

https://chatgpt.com/codex/tasks/task_e_68cc931e873c8324bb9b430a6ead69ad

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

Comment on lines +97 to +103
let statementForParsing = statement;
let forcedBehavior: 'REPLACE' | undefined;

if (upper.startsWith('REPLACE')) {
forcedBehavior = 'REPLACE';
statementForParsing = statement.replace(/^REPLACE\s+/i, 'INSERT OR REPLACE ');
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant