• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SAP / sqlalchemy-hana / 29505120374
96%
main: 95%

Build:
Build:
LAST BUILD BRANCH: renovate/lock-file-maintenance
DEFAULT BRANCH: main
Ran 17 Jul 2026 06:01AM UTC
Jobs 1
Files 23
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

15 Jul 2026 07:46AM UTC coverage: 95.816% (+8.3%) from 87.487%
29505120374

push

github

web-flow
Fix sql.false()/sql.true() rendering under use_native_boolean=False (#656)

## Summary

`HANAStatementCompiler.visit_is_true_unary_operator` and
`visit_is_false_unary_operator` unconditionally emit `... = TRUE` /
`... = FALSE`. When the dialect is configured with
`use_native_boolean=False`, SQLAlchemy's base `visit_true`/`visit_false`
render the wrapped element as an INT literal (`1`/`0`), so the compiled
WHERE becomes e.g. `WHERE 0 = TRUE` — which HANA rejects with error
**266 "BOOLEAN type is not comparable with INT"**.

This PR makes both overrides branch on
`self.dialect.supports_native_boolean` and fall back to an INT compare
in non-native mode. Native-mode behaviour is unchanged: the existing
`= TRUE` / `= FALSE` path is preserved, which is why these overrides
exist in the first place (HANA rejects a bare `WHERE TRUE` /
`WHERE FALSE`, per the comment above the methods).

## Reproducer

```python
from sqlalchemy import literal_column, select, sql
from sqlalchemy_hana.dialect import HANAHDBCLIDialect

dialect = HANAHDBCLIDialect(use_native_boolean=False)
stmt = select(literal_column("id")).where(sql.false())
print(stmt.compile(dialect=dialect))
# Before this PR:  SELECT id FROM DUMMY WHERE 0 = TRUE   <-- HANA error 266
# After this PR:   SELECT id FROM DUMMY WHERE 0 = 1
```

## Before / After

`select(literal_column("id")).where(sql.false())` with
`use_native_boolean=False`:

| | Before | After |
| -------------- | -------------------- |
---------------------------------- |
| Compiled SQL | `WHERE 0 = TRUE` | `WHERE 0 = 1` |
| HANA response | error 266 | executes; predicate is always false |

Same statement with `use_native_boolean=True` (unchanged):

|                | Before                 | After                  |
| -------------- | ---------------------- | ---------------------- |
| Compiled SQL   | `WHERE false = TRUE`   | `WHERE false = TRUE`   |

## Test evidence

Added `test_sql_unary_boolean_non_native` in `test/test_sql_compile.py`
tha... (continued)

10 of 11 new or added lines in 2 files covered. (90.91%)

13 existing lines in 1 file now uncovered.

1855 of 1936 relevant lines covered (95.82%)

0.96 hits per line

Uncovered Changes

Lines Coverage ∆ File
1
94.97
24.71% sqlalchemy_hana/dialect.py

Coverage Regressions

Lines Coverage ∆ File
13
94.97
24.71% sqlalchemy_hana/dialect.py
Jobs
ID Job ID Ran Files Coverage
1 29505120374.1 17 Jul 2026 06:01AM UTC 23
95.82
GitHub Action Run
Source Files on build 29505120374
  • Tree
  • List 23
  • Changed 2
  • Source Changed 2
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #29505120374
  • dfd388b7 on github
  • Prev Build on fix/native-boolean-false-int-compare (#29394405237)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc