Boolean fields compared as integers (SQLite pattern) #69

Open
opened 2026-03-27 04:06:13 +00:00 by cal · 1 comment
Owner

Problem

Boolean fields (Transaction.cancelled, Transaction.frozen) are compared using == 1 / == 0 instead of == True / == False. This is a SQLite-era pattern — SQLite stores booleans as integers, but PostgreSQL uses native booleans.

Peewee's BooleanField adapter handles some conversion, but comparing a boolean column to an integer literal is fragile and semantically incorrect on PostgreSQL.

Locations

  • app/routers_v3/transactions.py lines 78-85
  • app/db_engine.py lines 438, 439, 498-503, 559-563

Fix

Change all == 1 to == True and == 0 to == False for boolean fields.

Severity

High — most likely to cause runtime failures if Peewee's implicit casting changes.

## Problem Boolean fields (`Transaction.cancelled`, `Transaction.frozen`) are compared using `== 1` / `== 0` instead of `== True` / `== False`. This is a SQLite-era pattern — SQLite stores booleans as integers, but PostgreSQL uses native booleans. Peewee's `BooleanField` adapter handles some conversion, but comparing a boolean column to an integer literal is fragile and semantically incorrect on PostgreSQL. ## Locations - `app/routers_v3/transactions.py` lines 78-85 - `app/db_engine.py` lines 438, 439, 498-503, 559-563 ## Fix Change all `== 1` to `== True` and `== 0` to `== False` for boolean fields. ## Severity High — most likely to cause runtime failures if Peewee's implicit casting changes.
Claude added the
ai-working
label 2026-03-27 09:01:14 +00:00
Claude added the
ai-pr-opened
label 2026-03-27 09:04:26 +00:00
Collaborator

PR #94 opened: #94

Replaced all 10 integer comparisons on boolean fields with True/False literals:

  • transactions.py: 4 changes (cancelled == 1/0, frozen == 1/0)
  • db_engine.py: 6 changes (cancelled == 0 in the active team, SIL team, and LIL team blocks of get_roster_counts())
PR #94 opened: https://git.manticorum.com/cal/major-domo-database/pulls/94 Replaced all 10 integer comparisons on boolean fields with `True`/`False` literals: - `transactions.py`: 4 changes (`cancelled == 1/0`, `frozen == 1/0`) - `db_engine.py`: 6 changes (`cancelled == 0` in the active team, SIL team, and LIL team blocks of `get_roster_counts()`)
Claude removed the
ai-working
label 2026-03-27 09:04:34 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/major-domo-database#69
No description provided.