Repository navigation
Convert a Boolean column's 1/0 to a bool in the dialect - #20
Merged
Merged
Conversation
Before 23ai there is no BOOLEAN type: a Boolean column is a NUMBER, and the driver reads 1 or 0 back as a number. SQLAlchemy 2.0's Boolean converted that itself. From 2.1 the generic Oracle dialect's Boolean no longer does (its result_processor returns None) and relies on an output type handler that only the cx_Oracle / python-oracledb dialects install. So on 11g under SQLAlchemy 2.1 the compliance suite's BooleanTest.test_round_trip got 1 where it wanted True. The dialect now declares its own Boolean, as it already declares its own Date for the same reason. It converts a number to a bool and passes a native BOOLEAN's bool, and NULL, through unchanged. It is correct under 2.0.54 as well, where it replaces the conversion Boolean did itself. Measured on real 11g: BooleanTest passes 4/4 under both 2.1.0 and 2.0.54. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
lemenkov
force-pushed
the
sqlalchemy-2.1
branch
from
September 24, 2026 23:08
3b0dbc8 to
3856987
Compare
Merged
lemenkov
added a commit
that referenced
this pull request
Sep 24, 2026
Changes since 0.2.1: - A Boolean column's 1/0 is converted to a bool by the dialect itself (#20). SQLAlchemy 2.1 stopped doing it in the generic Oracle dialect, so before 23ai a Boolean came back as 1 or 0. - CI pins SQLAlchemy to one exact version, 2.0.54 (#19). The driver floor stays seerdb>=2.5.0: nothing here depends on an unreleased driver fix. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Peter Lemenkov <lemenkov@gmail.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.
Before 23ai there is no BOOLEAN type: a
Booleancolumn is a NUMBER, and the driver reads 1 or 0 back as a number. SQLAlchemy 2.0'sBooleanconverted that itself. From 2.1, the generic Oracle dialect's_OracleBoolean.result_processorreturnsNoneand relies on an output type handler that only the cx_Oracle / python-oracledb dialects install. So on 11g under SQLAlchemy 2.1, the compliance suite'sBooleanTest.test_round_tripgot1where it wantedTrue.Change
The dialect declares its own
Boolean,_SeerdbBoolean, as it already declares its ownDatefor the same reason. It converts a number to abool, and passes a native BOOLEAN'sbooland NULL through unchanged. It is correct under 2.0.54 as well, where it takes over the conversionBooleanused to do itself.Tests
test/test_boolean.py; the unit tests pass under both SQLAlchemy 2.1.0 and 2.0.54.BooleanTestpasses 4/4 under 2.1.0 and under 2.0.54.BooleanTestfailures were the driver's, fixed in Client: send a bool declared NUMBER as the NUMBER 0 or 1 seerdb#1202, after whichBooleanTestpasses 4/4 there too.Part of the SQLAlchemy 2.1 track: sqlalchemy-2.1, seerdb/seerdb#1203. It is independent of the CI pin in #19 and does not need it; with #19 merged, this PR's CI runs on 2.0.54.
🤖 Generated with Claude Code