Skip to content

fix: cast composite type columns to text in backfill selects - #2160

Open
entity-0-0-2 wants to merge 1 commit into
sequinstream:mainfrom
entity-0-0-2:fix/backfill-composite-text-encoding
Open

entity-0-0-2 wants to merge 1 commit into
sequinstream:mainfrom
entity-0-0-2:fix/backfill-composite-text-encoding

Conversation

@entity-0-0-2

@entity-0-0-2 entity-0-0-2 commented Oct 10, 2026 •

Copy link
Copy Markdown

Backfill silently writes NULL for Postgres composite-type columns while the stream path renders the same column as text, for example (EUR,42.00) (#2158). Deterministic data loss for every backfilled row.

The backfill reader selects composite columns because they pass has_encoder? for pg_typtype c/d/e (postgres.ex:1010), but load_rows nils any value whose Jason encoder is the Any fallback (postgres.ex:925-927, from df4a681, Oct 2024). The stream path falls back to the raw text rendering in value_caster.ex:75-80 instead.

safe_select_columns now casts composite columns to text in the backfill SELECT, matching what the stream path emits. Enums, domains, ranges and other special types are untouched. A test backfills a table with a composite column and asserts the text form: nil on main, (EUR,42.00) with the change. mix format, prod compile with warnings as errors and the postgres and table_reader suites pass.

Fixes #2158

Backfill selects picked custom composite type columns as-is, Postgrex
decoded them into values without a Jason.Encoder, and load_rows/2
silently turned them into nil, while the WAL replication path emitted
Postgres text representation like (EUR,42.00) for the same column.

Select composite columns (pg_typtype c) with an explicit ::text cast
and alias so backfilled rows carry the same text representation the
stream path produces.

This branch has not been deployed

No deployments
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.

Backfill silently nulls columns of custom composite types (no Jason.Encoder), while streamed changes correctly serialize them as text

1 participant