fix(drivers): show pagination for SELECTs with leading SQL comments#213
Open
ymadd wants to merge 1 commit into
Open
fix(drivers): show pagination for SELECTs with leading SQL comments#213ymadd wants to merge 1 commit into
ymadd wants to merge 1 commit into
Conversation
`is_select_query` did not strip leading `--` / `/* */` comments before checking for `SELECT`, while `returns_result_set` and `is_explainable_query` did. A SELECT preceded by a comment header was therefore routed to the fetch path but bypassed the pagination branch in `exec_on_*_conn`, returning `pagination: None` so the UI hid the controls entirely. Align it with the other helpers. Fixing the classifier alone exposed a latent bug in `strip_limit_offset`: it tokenised then rejoined with `" "`, collapsing newlines. For a query like `-- header\nSELECT ... LIMIT 50` the rejoined output became `-- header SELECT ... LIMIT 50 OFFSET 0`, which engines parse as one `--` comment line — silently no-op. Switched the tokenizer to track byte offsets and made `strip_limit_offset` slice the original input, preserving comments and whitespace verbatim. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
is_select_querynow strips leading--//* */comments before checking forSELECT, matchingreturns_result_setandis_explainable_query. Without this, aSELECTpreceded by a header-comment block was routed through the result-set fetch path but bypassed the pagination branch inexec_on_*_conn, returningpagination: Noneand hiding the UI controls entirely — so a 500-row result looked like a fixed slice with no way to advance.strip_limit_offsetthat the classifier change exposed: it tokenised then rejoined with" ", collapsing newlines. For a query like-- header\nSELECT ... LIMIT 50the rejoined output became-- header SELECT ... LIMIT 50 OFFSET 0, which MySQL/Postgres/SQLite all parse as a single--comment line — silently no-op. Switched the tokenizer to track byte offsets and madestrip_limit_offsetslice the original input, preserving comments and whitespace verbatim.',",`) into aread_quotedhelper while refactoring the tokenizer.Repro (before this PR)
Result: rows show, but the pagination bar is gone — only the first page is reachable.
After: pagination renders and pages can be navigated as expected.
Test plan
cargo test --lib drivers::common— 42 passed, including 4 new regression tests:test_is_select_query_with_leading_commentstest_build_paginated_query_with_leading_commentstest_build_paginated_query_multiline_comments_with_user_limittest_strip_limit_offset_preserves_leading_commentsSELECTreturning >page_size rows against MySQL, Postgres, SQLite; verify pagination bar renders and Next/Prev work.🤖 Generated with Claude Code