Repository navigation
fix: cast composite type columns to text in backfill selects - #2160
Open
entity-0-0-2 wants to merge 1 commit into
Open
entity-0-0-2 wants to merge 1 commit into
entity-0-0-2 wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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