Make boolean column reads and writes work on both storage tiers #62

Merged
weichen merged 2 commits from fix/pg-boolean-columns into main 2026-10-05 05:03:04 +00:00
2 Commits
Author SHA1 Message Date
weichen 4b93abbb2d Merge remote-tracking branch 'origin/main' into fix/pg-boolean-columns
ci / vet-and-test (pull_request) Successful in 40s
# Conflicts:
#	internal/store/auth.go
#	internal/store/projects.go
2026-10-05 05:01:01 +00:00
weichen 685bd0d171 Make boolean column reads and writes work on both storage tiers
ci / vet-and-test (pull_request) Successful in 46s
Why:
The dev runtime switched to the PostgreSQL tier and every conversation
endpoint started returning 500. Migrations define
conversations.pinned/archived/allow_cross_read/cross_private and
users.must_change_password/is_admin as BOOLEAN on PostgreSQL but
INTEGER on SQLite, while the store layer compared them with 0/1
literals, scanned them into int, and wrote them via boolInt().
Under pgx these fail with 42883 (operator does not exist: boolean =
integer), bool encode errors, or 42804 (column is of type boolean but
expression is of type integer).

Evidence:
- parent-repo main 4fd03ee with AGENT_PG_TEST_DSN:
  TestConversationFlagsAndTaskList and TestAdminAccountsAndSessions
  fail with the errors above; live GET /api/conversations returned
  "operator does not exist: boolean = integer (SQLSTATE 42883)".
- this branch: full ./internal/store suite green on the PostgreSQL
  tier (AGENT_PG_TEST_DSN against a scratch database), pgbus green,
  make test-backend green on the SQLite tier.
- scan into *bool and Go bool parameters are cross-dialect: pgx encodes
  bool natively; database/sql converts bool<->0/1 for SQLite.
- pre-existing and out of scope: ./internal/runmgr PG integration tests
  fail on main too (gin_trgm_ops invisible inside the search_path
  isolation schema, 42704).

Impact:
Conversations list/detail/flags and user auth-state reads/writes now
work identically on both storage tiers; SQLite behavior is unchanged.

Refs: Dev task .task/fix-pg-boolean-columns.md
2026-10-04 14:51:48 +00:00