Boolean fields compared as integers (SQLite pattern) #69
Labels
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/major-domo-database#69
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Boolean fields (
Transaction.cancelled,Transaction.frozen) are compared using== 1/== 0instead of== True/== False. This is a SQLite-era pattern — SQLite stores booleans as integers, but PostgreSQL uses native booleans.Peewee's
BooleanFieldadapter handles some conversion, but comparing a boolean column to an integer literal is fragile and semantically incorrect on PostgreSQL.Locations
app/routers_v3/transactions.pylines 78-85app/db_engine.pylines 438, 439, 498-503, 559-563Fix
Change all
== 1to== Trueand== 0to== Falsefor boolean fields.Severity
High — most likely to cause runtime failures if Peewee's implicit casting changes.
PR #94 opened: #94
Replaced all 10 integer comparisons on boolean fields with
True/Falseliterals:transactions.py: 4 changes (cancelled == 1/0,frozen == 1/0)db_engine.py: 6 changes (cancelled == 0in the active team, SIL team, and LIL team blocks ofget_roster_counts())