Skip to content

fix: postgres json/jsonb null comparison causes startup failure#17

Merged
martinhoefling merged 1 commit into
mainfrom
fix/postgres-json-null-comparison
Jun 1, 2026
Merged

fix: postgres json/jsonb null comparison causes startup failure#17
martinhoefling merged 1 commit into
mainfrom
fix/postgres-json-null-comparison

Conversation

@martinhoefling

@martinhoefling martinhoefling commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • PostgreSQL has no implicit cast between json and jsonb, so the migration queries in _upgrade_schema and _needs_migration_sync that compared a json column against 'null'::jsonb raised operator does not exist: json = jsonb
  • Changed both occurrences to value::text = 'null', which works correctly regardless of whether the column is json or jsonb
  • Bumps version to 0.3.2

Root cause

BaseSQLStore defines the value column using SQLAlchemy's generic JSON type, which PostgreSQL maps to json (not jsonb). The migration code then tried to compare it with 'null'::jsonb, which PostgreSQL rejects.

Test plan

  • All 50 existing tests pass (pytest)
  • Ruff lint and format checks pass
  • Manually verify fresh TimescaleDB database initialises without error

🤖 Generated with Claude Code

…tgres migrations

PostgreSQL has no implicit cast between json and jsonb, so comparing a json
column with 'null'::jsonb raises "operator does not exist: json = jsonb".
Cast to text instead, which works for both json and jsonb column types.

Fixes startup failure on fresh databases with the TimescaleDB backend.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@martinhoefling martinhoefling merged commit 1167459 into main Jun 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant