Skip to content

fix(postgres): strip trailing semicolon on unlimited query path - #2490

Merged
goldmedal merged 1 commit into
Canner:mainfrom
Bartok9:fix/postgres-strip-unlimited-query
Jul 20, 2026
Merged

fix(postgres): strip trailing semicolon on unlimited query path#2490
goldmedal merged 1 commit into
Canner:mainfrom
Bartok9:fix/postgres-strip-unlimited-query

Conversation

@Bartok9

@Bartok9 Bartok9 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Strip trailing ; on Postgres unlimited query() (same helper as LIMIT wrap / dry_run).

Motivation

Unlimited path executed raw terminated SQL while limited/dry_run already stripped — inconsistent client paste behavior.

Verification

  • Without fix: execute keeps ; (test fail)
  • With fix: pytest tests/unit/test_postgres_semicolon_unlimited.py → 2 passed
  • Apache-2.0 core/**

Files

  • core/wren/src/wren/connector/postgres.py
  • core/wren/tests/unit/test_postgres_semicolon_unlimited.py

Summary by CodeRabbit

  • Bug Fixes

    • Improved PostgreSQL query handling by consistently removing trailing semicolons/whitespace from user-provided SQL before execution in both unlimited and limited result scenarios.
    • Ensured limit-wrapped queries are constructed from the cleaned SQL for consistent behavior.
  • Tests

    • Added unit coverage verifying trailing semicolon stripping works for queries without a limit and for queries where a limit is applied.

@github-actions github-actions Bot added python Pull requests that update Python code core labels Jul 13, 2026
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2ee53982-e18b-4a60-9abb-2c958d61b04d

📥 Commits

Reviewing files that changed from the base of the PR and between 2141cc6 and f63bb9b.

📒 Files selected for processing (2)
  • core/wren/src/wren/connector/postgres.py
  • core/wren/tests/unit/test_postgres_semicolon_unlimited.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • core/wren/src/wren/connector/postgres.py
  • core/wren/tests/unit/test_postgres_semicolon_unlimited.py

Walkthrough

PostgresConnector.query now strips trailing semicolons before execution, regardless of whether a LIMIT is supplied. Unit tests cover unlimited execution and limited subquery wrapping.

Changes

Postgres SQL normalization

Layer / File(s) Summary
Normalize SQL before optional LIMIT wrapping
core/wren/src/wren/connector/postgres.py, core/wren/tests/unit/test_postgres_semicolon_unlimited.py
Trailing semicolons are removed before direct execution or LIMIT subquery construction, with mocked tests covering both query modes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: goldmedal

Poem

I’m a rabbit tidying SQL bright,
Trimming semicolons left and right.
With limits or none, queries run clean,
Wrapped just so, as they should be seen.
Tests hop along to prove the scene.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: stripping trailing semicolons on the PostgreSQL unlimited query path.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

dry_run and limited query already strip; unlimited execute did not.
@goldmedal
goldmedal merged commit 7e4cfca into Canner:main Jul 20, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants