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

mathieuprog / polymorphic_embed / 44b1449e6d2c12d65d28681206a374d0a3cb0479-PR-148
86%
master: 83%

Build:
Build:
LAST BUILD BRANCH: fix-embeds-cast-and-forms
DEFAULT BRANCH: master
Ran 24 Oct 2026 09:24AM UTC
Jobs 8
Files 6
Run time 1min
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

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

Uncovered Changes

Lines Coverage ∆ File
17
88.04
4.84% lib/polymorphic_embed.ex
16
68.63
lib/polymorphic_embed/embedded.ex
1
95.08
2.06% lib/polymorphic_embed/html/helpers.ex
1
58.06
3.23% lib/polymorphic_embed/options_validator.ex

Coverage Regressions

Lines Coverage ∆ File
9
88.04
4.84% lib/polymorphic_embed.ex
Jobs
ID Job ID Ran Files Coverage
1 44b1449e6d2c12d65d28681206a374d0a3cb0479-PR-148.1 24 Oct 2026 09:24AM UTC 6
85.81
GitHub Action Run
2 44b1449e6d2c12d65d28681206a374d0a3cb0479-PR-148.2 24 Oct 2026 09:24AM UTC 6
85.81
GitHub Action Run
3 44b1449e6d2c12d65d28681206a374d0a3cb0479-PR-148.3 24 Oct 2026 09:24AM UTC 6
85.81
GitHub Action Run
4 44b1449e6d2c12d65d28681206a374d0a3cb0479-PR-148.4 24 Oct 2026 09:24AM UTC 6
85.81
GitHub Action Run
5 44b1449e6d2c12d65d28681206a374d0a3cb0479-PR-148.5 24 Oct 2026 09:24AM UTC 6
85.81
GitHub Action Run
6 44b1449e6d2c12d65d28681206a374d0a3cb0479-PR-148.6 24 Oct 2026 09:24AM UTC 6
85.81
GitHub Action Run
7 44b1449e6d2c12d65d28681206a374d0a3cb0479-PR-148.7 24 Oct 2026 09:24AM UTC 6
85.81
GitHub Action Run
8 44b1449e6d2c12d65d28681206a374d0a3cb0479-PR-148.8 24 Oct 2026 09:24AM UTC 6
85.81
GitHub Action Run
Source Files on build 44b1449e6d2c12d65d28681206a374d0a3cb0479-PR-148
  • Tree
  • List 6
  • Changed 3
  • Source Changed 0
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Pull Request #148
  • PR Base - master (#6AA26ED7...)
  • Delete
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