Fix binding bytes values for VARBINARY columns - #630
Open
hashhar wants to merge 1 commit into
Open
Conversation
hashhar
force-pushed
the
hashhar/626-varbinary-literal
branch
from
August 18, 2026 14:37
bf6d721 to
56e3ce5
Compare
…paths Binary() in trino/dbapi.py called .encode() on every value unconditionally, raising AttributeError for bytes/bytearray/memoryview. It now passes those through as-is. SQLAlchemy's default literal_processor for binary types also renders values as a quoted string, which breaks for non-UTF-8 bytes. Added a VARBINARY type in trino/sqlalchemy/datatype.py that renders X'<hex>', wired in via dialect.colspecs for reflected and generic LargeBinary/BINARY columns.
hashhar
force-pushed
the
hashhar/626-varbinary-literal
branch
from
August 19, 2026 22:38
56e3ce5 to
861823a
Compare
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.
Description
Binary()intrino/dbapi.pycalled.encode()on every value unconditionally, raisingAttributeErrorforbytes/bytearray/memoryview. It now passes those through as-is.SQLAlchemy's default
literal_processorfor binary types also renders values as a quoted string, which breaks for non-UTF-8 bytes. Added aVARBINARYtype intrino/sqlalchemy/datatype.pythat rendersX'<hex>', wired in viadialect.colspecsfor reflected and genericLargeBinary/BINARYcolumns.Non-technical explanation
You can now write
bytesvalues into aVARBINARYcolumn, whether you're using the raw client or SQLAlchemy.Release notes
(x) Release notes are required, with the following suggested text:
Fixes #626