Repository navigation
fix(sqlalchemy): keep colons in SQL string literals literal - #4279
Merged
anakin87 merged 2 commits intoNov 24, 2026
Merged
Conversation
astroknot-sheep
requested review from
anakin87
and removed request for
a team
November 16, 2026 15:31
Contributor
Coverage report (sqlalchemy)Click to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
anakin87
requested changes
Nov 23, 2026
anakin87
left a comment
Member
There was a problem hiding this comment.
Hello!
I simply recommend using exec_driver_sql() instead of text().
Replacing : might cause different issues.
Contributor
Author
|
Thanks, that's cleaner. Switched both call sites to |
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.
Related Issues
Proposed Changes:
SQLAlchemyTableRetrieverpassed queries andinit_scriptstatements straight totext(), which reads:nameas a bind parameter even inside string literals. The component never passes parameters, so a query like... WHERE body = 'see :ref'returnedA value is required for bind parameter 'ref', and a seed statement with JSON such as'{"k":1}'madewarm_up()raise.Both call sites now use
Connection.exec_driver_sql(), so the SQL goes to the driver as written and nothing is parsed for bind parameters. They passexecution_options={"no_parameters": True}, so drivers like psycopg2 also don't treat%(e.g. inLIKE 'a%') as a parameter marker.How did you test it?
test_colons_in_string_literals_are_not_bind_parameters(seed data and query both contain colons). It fails onmainand passes with this change.pytest testsinintegrations/sqlalchemy: 16 passed.ruff check,ruff format --checkandmypy -p haystack_integrations.components.retrievers.sqlalchemyare clean.Notes for the reviewer
I used AI assistance while investigating and drafting this PR. I reviewed every line and ran the tests myself.
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:.