Expand description
Option<StructEmbed> model fields.
A nullable embedded struct stores a nullable bool presence column
(NULL = None, true = Some) plus its flattened leaf columns forced
nullable. None is NULL in the presence column, symmetric with
Option<scalar> and an embedded enum’s discriminant. This disambiguates
None from a Some whose fields happen to all be empty.
A single-column embed (a newtype Option<Code> where Code(String)) is
the exception: its one flattened leaf already collapses to the field name,
so it reuses that leaf as the head column (NULL = None) instead of a
dedicated presence column that would collide with it — exactly like
Option<scalar>.
Functions§
- option_
embed_ create_ ops - Driver-op coverage for create. A
Somewritestrueto the presence column plus the leaf values; aNonewritesNULLto the presence column and every leaf column. The column set is identical in both cases —Noneis a concrete all-NULLrow, not an omitted/absent one. - option_
embed_ crud - Round-trip both
SomeandNone. - option_
embed_ db_ schema - The DB schema: a nullable
boolpresence column named after the field, plus one nullable column per flattened leaf field. - option_
embed_ filter_ eq - Whole-value
.eq(Some(..))matches only the equalSomerow, neverNone. - option_
embed_ filter_ ops - Driver-op coverage for filters.
.is_none()/.is_some()emit a predicate on the single presence column (IS NULL/NOT (.. IS NULL)), never a check distributed across the leaf columns. - option_
embed_ filter_ presence .is_none()/.is_some()filter on the presence column.- option_
embed_ update - Updating the whole value in both directions:
Some→NoneandNone→Some. - option_
embed_ update_ ops - Driver-op coverage for updates. Setting
Someassignstrue+ the leaf values; settingNoneassignsNULLto the presence column and every leaf. - option_
newtype_ create_ ops - Driver-op coverage.
Somewrites the inner value to the singlecodecolumn;NonewritesNULLto it. There is no separate presence column. - option_
newtype_ crud - Round-trip both
SomeandNone. - option_
newtype_ db_ schema - The DB schema: exactly one nullable column named after the field, with no separate presence column.
- option_
newtype_ filter_ eq - Whole-value
.eq(Some(..))on the reused head column matches only the equalSomerow, neverNone. - option_
newtype_ filter_ ops - Driver-op coverage for filters:
.is_none()emitscode IS NULLon the single reused column. - option_
newtype_ filter_ presence .is_none()/.is_some()filter on the reused head (the single leaf) column.- option_
newtype_ update - Updating the whole value in both directions:
Some→NoneandNone→Some. - option_
newtype_ wrapping_ option_ rejected Option<Newtype>where the newtype wraps anOption(MaybeBody(Option<String>)) has no unambiguous single-column mapping — the one column can’t tellNonefromSome(MaybeBody(None)), and a dedicated presence column would collide with the newtype leaf. It is rejected at schema build rather than silently collapsingSome(None)toNone.- option_
struct_ nullable_ inner_ disambiguates - Contrast with the rejected newtype above: a named single field whose inner
is itself nullable (
Wrapper { value: Option<String> }) keeps the dedicated presence column, so it round-tripsSome(value: None)distinctly fromNone— the disambiguation a single reused column can’t provide.