Repository navigation
fix(persistence): compile dialect-safe boolean defaults - #2087
RaghavChamadiya merged 1 commit into
Conversation
Why: - Additive PostgreSQL reconciliation rejected integer defaults for missing BOOLEAN columns. Changes: - Compile Python boolean defaults as typed SQLAlchemy literals for the active dialect. - Cover false and true defaults on SQLite and PostgreSQL dialects. Testing: - uv run pytest -q tests/unit/persistence/test_schema_reconciliation.py - uv run ruff check packages/core/src/repowise/core/persistence/database.py tests/unit/persistence/test_schema_reconciliation.py - git diff --check
RaghavChamadiya
left a comment
There was a problem hiding this comment.
Right fix in the right place. Compiling the typed literal against the dialect is what _add_column_ddl should have been doing from the start: bool is not int in PostgreSQL, and DEFAULT 0 on a BOOLEAN column is a syntax error there, so the legacy-column path could not add a boolean column to a Postgres index at all. The parametrized test pinning 0/1 on SQLite and false/true on Postgres is the assertion I would have asked for.
Non-blocking: the diff carries two formatting-only hunks (the blank line at database.py:46 and the f-string reflow in the _run lambda) that are not part of the fix. Not worth another round trip, but this repo does not run ruff format over the tree, so please keep future diffs to the change itself.
Summary
0/1for SQLite andfalse/truefor PostgreSQL during additive column reconciliationThis fixes legacy PostgreSQL upgrades for every model Boolean backed only by a Python default, including both
conversations.pinnedandcoverage_files.mapping_partial.Related Issues
Fixes #2059
Test Plan
uv run pytest -q tests/unit/persistence/test_schema_reconciliation.py(13 passed)uv run ruff check packages/core/src/repowise/core/persistence/database.py tests/unit/persistence/test_schema_reconciliation.pygit diff --checkRisk
Repowise change risk: 18th percentile (Below typical / low review priority). Numeric and string defaults retain their existing rendering; only Python
booldefaults use the dialect compiler.