Skip to content

fix: Fix row limit detection for multiline LIMIT clauses#1594

Open
Anjanna wants to merge 2 commits intodbcli:mainfrom
Anjanna:fix-limit-newline
Open

fix: Fix row limit detection for multiline LIMIT clauses#1594
Anjanna wants to merge 2 commits intodbcli:mainfrom
Anjanna:fix-limit-newline

Conversation

@Anjanna
Copy link
Copy Markdown

@Anjanna Anjanna commented May 10, 2026

Description

Summary

Fixes #1592

Fixes pgcli's row limit detection when a SQL query contains a LIMIT clause followed by a newline.

Previously, pgcli checked for LIMIT using a string search for "limit ", so queries like this were not recognized as already limited:

SELECT *
FROM foo
LIMIT
    10000;

As a result, pgcli could incorrectly apply its configured row limit and show the row-limit warning. This change uses parsed SQL tokens to detect real LIMIT keywords, including multiline and tab-separated formatting, while ignoring LIMIT inside strings or comments.

Checklist

  • I've added this contribution to the changelog.rst.
  • I've added my name to the AUTHORS file (or it's already there).
  • I installed pre-commit hooks (pip install pre-commit && pre-commit install).
  • I verified that my changes work as expected (this may include manually testing them in your local environment, or in other available environments). Cross this out if not relevant (for example, if you're making a documentation change).
  • Please squash merge this pull request (uncheck if you'd like us to merge as multiple commits)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LIMIT is ignored when the LIMIT keyword is followed by a newline.

1 participant