• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mathieuprog / polymorphic_embed
86%
master: 83%

Build:
Build:
LAST BUILD BRANCH: fix-embeds-cast-and-forms
DEFAULT BRANCH: master
Repo Added 13 Nov 2022 06:48AM UTC
Token 0FgC2mLQUk5OpCbIW5cyZlxOOySGoDiS3 regen
Build 104 Last
Files 5
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

LAST BUILD ON BRANCH ecto-parity
branch: ecto-parity
CHANGE BRANCH
x
Reset
Sync Branches
  • ecto-parity
  • al/ci
  • al/quiet-tests
  • fix-embeds-cast-and-forms
  • fix-get-type
  • fix-normalize-embed-params
  • fix-param-handling
  • fix-security-audit
  • fix-with-ecto-3.12
  • fix/warnings
  • hidden-input-for-type
  • master
  • patch-1
  • refs/pull/132/merge
  • refs/pull/148/merge
  • remove-alias-expansion-warning

24 Oct 2026 09:23AM UTC coverage: 85.809% (+2.9%) from 82.933%
44b1449e6d2c12d65d28681206a374d0a3cb0479-PR-148

Pull #148

github

nduitz
Add put_polymorphic_embed/3

When the cast puts changesets into the changes of a polymorphic field,
the field has an Ecto embed type with one schema module. Ecto's
put_change/3, update_change/3 and change/2 then check each child against
that module, so they raise for children of another type. Ecto has no
place where polymorphic_embed can change that check.

put_polymorphic_embed/3 works as Ecto.Changeset.put_embed/4, but it finds
the matching data row by module and primary key, per element. So a list
can hold more than one type, and a single embed can change its type. It
accepts structs, changesets, maps and keyword lists. The type of a map
comes from its type field, from the data row with the same primary key,
or from the only type of the field. A new child gets its id at once, as
in the cast.

The changelog lists the new function, and the limit of Ecto's functions
as a breaking change.

The function keeps the changeset function that an earlier cast stored
for the forms, for example a with: function. An empty list replaces
data that holds only entries from the load options. The tests also
check that ordinary embeds in the data of a put child get their ids on
insert, and that the form keeps the id of a struct that the caller
gives.

As Ecto.Changeset.put_embed/4 does, the function gives the error "is
invalid" for a value that the field does not accept, for example nil for
a list of embeds, and keeps the data and the changes. A put inside a
prepare function of the parent prepares the embeds at once, as the cast
does.
Pull Request #148: Ecto parity

261 of 296 new or added lines in 4 files covered. (88.18%)

9 existing lines in 1 file now uncovered.

520 of 606 relevant lines covered (85.81%)

520.2 hits per line

Relevant lines Covered
Build:
Build:
606 RELEVANT LINES 520 COVERED LINES
520.2 HITS PER LINE
Source Files on ecto-parity
  • Tree
  • List 6
  • Changed 3
  • Source Changed 0
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line

Recent builds

Builds Branch Commit Type Ran Committer Via Coverage
44b1449e... ecto-parity Add put_polymorphic_embed/3 When the cast puts changesets into the changes of a polymorphic field, the field has an Ecto embed type with one schema module. Ecto's put_change/3, update_change/3 and change/2 then check each child against that modul... Pull #148 24 Oct 2026 09:24AM UTC nduitz github
85.81
322096be... ecto-parity Add put_polymorphic_embed/3 When the cast puts changesets into the changes of a polymorphic field, the field has an Ecto embed type with one schema module. Ecto's put_change/3, update_change/3 and change/2 then check each child against that modul... Pull #148 23 Oct 2026 12:34PM UTC nduitz github
85.5
e4b885da... ecto-parity Add put_polymorphic_embed/3 When the cast puts changesets into the changes of a polymorphic field, the field has an Ecto embed type with one schema module. Ecto's put_change/3, update_change/3 and change/2 then check each child against that modul... Pull #148 23 Oct 2026 11:34AM UTC nduitz github
84.35
f333f9a0... ecto-parity Add regression tests for inserts, forms and load options A review of the change that keeps the child changesets in the changes found these flows. The tests check that: - an insert keeps embeds of more than one type that are only in the data, a... Pull #148 23 Oct 2026 11:04AM UTC nduitz github
83.1
7c4b7e9b... ecto-parity Remove the separate test for the id match of embeds_many The test "cast embeds_many keeps the data of a row that it matches by id" checked the id match while the mirrored Ecto test "cast embeds_many changing schemas" still failed. That test now p... Pull #148 23 Oct 2026 10:14AM UTC nduitz github
84.26
3ce0752a... ecto-parity Test that nil for a list of embeds is invalid Commit 2985b48 made nil for a list of embeds invalid, as in Ecto, and removed contexts2: nil from the params of an existing test. The new test checks the change in polymorphic_embed_test.exs for both ... Pull #148 23 Oct 2026 10:03AM UTC nduitz github
84.26
d74e2b2a... ecto-parity Build polymorphic embed forms as phoenix_ecto does PolymorphicEmbed.HTML.Helpers.to_form/4 now follows the rules that phoenix_ecto uses for embeds_one and embeds_many: - A child form uses the child changeset from changes, with its own params a... Pull #148 22 Oct 2026 12:42PM UTC nduitz github
84.26
See All Builds (104)

Badge your Repo: polymorphic_embed

We detected this repo isn’t badged! Grab the embed code to the right, add it to your repo to show off your code coverage, and when the badge is live hit the refresh button to remove this message.

Could not find badge in README.

Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

Refresh
  • Settings
  • Repo on GitHub
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc