OR-ing the two variant-gated predicates on the shared creature_name column
is the natural way to query a single shared column across variants: “any
creature named Bob, regardless of variant”. This used to panic in the SQL
serializer (issue #1061) because factoring lifted the shared predicate out
from under its variant gates, exposing the decode’s unreachable Error else
branch.
A field declared #[shared(name)] in two variants coalesces into a single
shared, nullable column rather than producing one column per variant. The
table therefore has exactly one creature_name column alongside each
variant’s own distinct column.
The #[shared(name)] declaration surfaces in the app schema as the field’s
shared identifier; both variants’ name fields carry the same identifier,
which is what drives the column coalescing.
Updating the whole enum field — including switching variants — re-encodes the
shared column correctly. The merged per-variant encode must select the arm
matching the new discriminant, so the shared column follows the value into
its new variant while the old variant’s column is cleared to NULL.
Both variants store their name in the same physical creature_name
column. A variant-rooted filter on that column keeps its implicit variant
gate, so human().name().eq("Bob") matches only Human rows even though an
Animal stores the same value in the same column — the discriminant
disambiguates the shared column per variant.