Skip to content

Preserve invalid scalar embed params - #7

Merged
fishtreesugar merged 1 commit into
cdc-fixesfrom
codex/handle-scalar-embed-params
Jun 23, 2026
Merged

Preserve invalid scalar embed params#7
fishtreesugar merged 1 commit into
cdc-fixesfrom
codex/handle-scalar-embed-params

Conversation

@fishtreesugar

Copy link
Copy Markdown
Owner

What changed

  • Preserve scalar params during schema transformation so Ecto can handle invalid embed input.
  • Add regression coverage for a scalar item inside embeds_many.
  • Add regression coverage for a scalar value passed to embeds_one.

Why

A scalar item supplied to an embedded schema has no fields to map. It previously fell through to transform_from_struct/3, where get_params_field_value/3 crashed before Ecto could validate the input.

Returning the scalar unchanged allows cast_embed to produce the expected type validation error instead of raising.

Impact

Invalid scalar values for embeds_one and scalar elements inside embeds_many now return normal changeset errors.

Validation

  • mix format --check-formatted lib/params.ex test/strukt_test.exs
  • mix test test/strukt_test.exs — 51 tests passed
  • git diff --check

@fishtreesugar fishtreesugar changed the title [codex] preserve invalid scalar embed params Preserve invalid scalar embed params Jun 23, 2026
@fishtreesugar
fishtreesugar marked this pull request as ready for review June 23, 2026 22:29
@fishtreesugar
fishtreesugar merged commit 630bb27 into cdc-fixes Jun 23, 2026
8 checks passed
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.

1 participant