Skip to content

fix: preserve literal percent signs in hybrid search - #305

Merged
hnwyllmm merged 1 commit into
developfrom
fix/304-hybrid-search-literal-percent
Dec 1, 2026
Merged

hnwyllmm merged 1 commit into
developfrom
fix/304-hybrid-search-literal-percent

Conversation

@hnwyllmm

@hnwyllmm hnwyllmm commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Pass None to PyMySQL when there are no bind arguments, in both cursor lifecycles. This preserves literal percent signs in complete SQL while leaving non-empty argument binding unchanged.
  • Add driver-level coverage for literal percent signs and percent signs inside bound values. Add a full-text-only hybrid search regression that checks the actual document hit without relying on a vector route.

Validation

  • On the original code, the two unbound cursor cases and the embedded hybrid search regression reproduced the reported formatting error; the two bound-value controls passed.
  • After the fix, 17 tests passed across the cursor tests, hybrid SQL rewrite tests, and embedded hybrid search suite (macOS arm64, Python 3.12, PyMySQL 1.1.2, pylibseekdb 1.4.1.post2). Server and OceanBase variants were not run locally.
  • Ruff check, Ruff format check, and git diff --check passed.

Closes #304.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue that could affect queries containing percent signs, including searches for documents with percent signs in their text.
    • Improved handling of searches with and without supplied parameters, so percent signs are interpreted correctly in both cases.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Cursor execution now passes None when parameters are empty, in both cursor-management paths. Regression tests cover percent signs in SQL and bound values, plus full-text hybrid search for a document containing a percent sign.

Changes: Cursor percent handling

Layer / File(s) Summary
Normalize empty parameters and validate percent handling
src/pyseekdb/client/client_base.py, tests/unit_tests/test_cursor_execution.py, tests/integration_tests/test_collection_hybrid_search.py
Both cursor paths pass None for empty parameters and preserve nonempty parameters. Unit tests cover percent signs in SQL and bound values. An integration test covers hybrid search for a document containing a percent sign.

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: y1-l1n

Merge Risk: Minimal · up to bdfdf

This change stops literal percent signs in hybrid search from raising a formatting error when no bind parameters are present. Binding with parameters is unchanged. No merge-blocking risk is evident.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix: preserve literal percent signs in hybrid search" matches the main change. The PR passes None to cursor execution when there are no bind parameters, so literal % characters in complete …
Linked Issues check Passed [#304] The issue requires that the embedded hybrid_search path stop applying Python %-formatting to SQL when no bind parameters exist, and keep binding when parameters exist. The whole-PR summary stat…
Out of Scope Changes check Passed All changes in the PR relate to #304. The production change is limited to _execute_query_with_cursor in src/pyseekdb/client/client_base.py (+5/-3 per the summary), which is the helper named in the iss…
Full details: Title check

Explanation

The title "fix: preserve literal percent signs in hybrid search" matches the main change. The PR passes None to cursor execution when there are no bind parameters, so literal % characters in complete SQL are not formatted by PyMySQL. The title names the bug (literal percent signs) and the affected feature (hybrid search), which matches the linked issue #304 and the changed client_base.py code. It is concise, has no file list or vague wording, and follows a conventional commit prefix.

Full details: Linked Issues check

Explanation

[#304] The issue requires that the embedded hybrid_search path stop applying Python %-formatting to SQL when no bind parameters exist, and keep binding when parameters exist. The whole-PR summary states that BaseClient._execute_query_with_cursor now passes None to cursor execution when params is empty, in both cursor-management paths, and passes non-empty lists unchanged. The issue states that both set_sql (client_base.py line ~4729) and query_sql (line ~4767) go through this helper with [], so the change covers both statements. The added unit tests in tests/unit_tests/test_cursor_execution.py assert that literal '%' in SQL with [] reaches Cursor._query unchanged (with and without context manager), and that '%s' with ['record%123'] still binds correctly. The added integration test test_hybrid_search_full_text_with_percent in tests/integration_tests/test_collection_hybrid_search.py covers the full-text-only regression with '5%'. Limits: the source diff for client_base.py could not be read (changed blobs missing from checkout), so the code change is established from the PR summary and the test file at head, not from the diff itself. Tests were not run in this review. The optional parameterization of the SET @search_parm statement is not required by the issue.

Full details: Out of Scope Changes check

Explanation

All changes in the PR relate to #304. The production change is limited to _execute_query_with_cursor in src/pyseekdb/client/client_base.py (+5/-3 per the summary), which is the helper named in the issue. The unit test file and the integration test are regression tests for the same formatting failure. No unrelated source, API, or declaration changes are reported (the summary lists no public declaration changes). The source diff could not be read directly, so this verdict relies on the PR summary and the test file contents.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Pylint (4.1.3)

Pylint used default settings because repository settings are unavailable in automated reviews.

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cd172643-9244-4128-b7b3-4406e9fca793
Commits

Reviewing files that changed from the base of the PR and between 3f20145 and bdfdf4e.

Files selected for processing: 3

  • src/pyseekdb/client/client_base.py
  • tests/integration_tests/test_collection_hybrid_search.py
  • tests/unit_tests/test_cursor_execution.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@hnwyllmm
hnwyllmm merged commit cd96d93 into develop Dec 1, 2026
12 checks passed
@hnwyllmm
hnwyllmm deleted the fix/304-hybrid-search-literal-percent branch December 1, 2026 09:41
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.

[Bug]: hybrid_search raises TypeError: not enough arguments for format string when query text contains '%'

1 participant