Skip to content

store: Select entity ids as text in FindPossibleDeletionsQuery - #6789

Open
dimitrovmaksim wants to merge 1 commit into
masterfrom
fix/entity-changes-mixed-id-types
Open

dimitrovmaksim wants to merge 1 commit into
masterfrom
fix/entity-changes-mixed-id-types

Conversation

@dimitrovmaksim

@dimitrovmaksim dimitrovmaksim commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #6695. Supersedes #6709.

Root cause

FindPossibleDeletionsQuery selected each id in its column type (text, bytea or int8). That broke the index-node entityChangesInBlock in two independent ways:

Fix

Select the id as text in every branch: encode(e.id, 'hex') for Bytes and e.id::text for String/Int8. encode doesn't depend on bytea_output, and Bytes::from_str parses its bare hex. as id is needed because encode(...) would otherwise name the column encode, and EntityDeletion reads columns by name.

Scope

Only the read-only entityChangesInBlock path changes; indexing and query serving are unaffected. Related: #6742 fixed the same endpoint for immutable entities.

Test

find_changes_with_bytes_ids, find_changes_with_int8_ids and find_changes_with_mixed_id_types update and delete entities, then check find_changes. On master each fails: the first two with the decode errors above, the mixed one with the UNION error.

The deletions query returned each id in its column type (text, bytea
or int8). Schemas mixing id types made Postgres reject the UNION, and
since EntityDeletion reads the id as text, Bytes or Int8 ids failed to
decode, or rarely decoded to a wrong id, for any entity updated or
deleted at the block, even without mixing.

Fixes #6695
@dimitrovmaksim
dimitrovmaksim force-pushed the fix/entity-changes-mixed-id-types branch from 5d05300 to 624bea5 Compare November 18, 2026 15:54

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.

entityChangesInBlock fails with "UNION types bytea and text cannot be matched" on schemas mixing Bytes and String IDs

1 participant