Skip to content

Convert a Boolean column's 1/0 to a bool in the dialect - #20

Merged
lemenkov merged 1 commit into
seerdb:masterfrom
lemenkov:sqlalchemy-2.1
Sep 24, 2026
Merged

lemenkov merged 1 commit into
seerdb:masterfrom
lemenkov:sqlalchemy-2.1

Conversation

@lemenkov

Copy link
Copy Markdown
Member

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 _OracleBoolean.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.

Change

The dialect declares its own Boolean, _SeerdbBoolean, 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 takes over the conversion Boolean used to do itself.

Tests

  • New unit test test/test_boolean.py; the unit tests pass under both SQLAlchemy 2.1.0 and 2.0.54.
  • Measured on real 11g, BooleanTest passes 4/4 under 2.1.0 and under 2.0.54.
  • On 23ai, 2.1's remaining BooleanTest failures were the driver's, fixed in Client: send a bool declared NUMBER as the NUMBER 0 or 1 seerdb#1202, after which BooleanTest passes 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

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
lemenkov merged commit 8fce6bb into seerdb:master Sep 24, 2026
15 checks passed
@lemenkov lemenkov mentioned this pull request Sep 24, 2026
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>
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.

1 participant