Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
2420a2a
handling cases where only a non-polymorphic changeset error exists
bashar-qassis Oct 20, 2021
0e7aaf5
extend merge_polymorphic_keys to look for PolymorphicEmbed inside ect…
hamzahejja Nov 4, 2021
e85b2b0
handle Ecto Embedded with cardinality: :many in traverse_errors
hamzahejja Nov 7, 2021
f03d3ee
use if instead of with for compact form
hamzahejja Nov 8, 2021
06fb45e
ensure that change is indeed a list and not nil
hamzahejja Nov 8, 2021
fddf4f5
Adding capability to customize traverse_errors per module for paramet…
bashar-qassis Jan 31, 2022
cc956a3
Merge pull request #2 from Userpilot/customizable-traverse-errors
DialaHamadneh Jan 31, 2022
0d22e90
fix type determination for default and custom type fields
woylie Oct 9, 2022
7c8871b
ignore .elixir_ls folder
woylie Nov 13, 2022
27c2668
split CI workflow
woylie Nov 13, 2022
2fe9af0
Merge branch 'master' into fixing-traverse-errors
bashar-qassis Jan 31, 2023
8e5007c
remove extra new line
bashar-qassis Jan 31, 2023
7c0fb10
suppress failing tests errors
bashar-qassis Jan 31, 2023
fdec5fc
downgrade json to 1.2
bashar-qassis Jan 31, 2023
813e0f6
Remove error from example code
Elmseld Mar 31, 2023
eccb0ef
fix error traversing from :embed type fields with many cardinality an…
Tamara-Adeeb Apr 13, 2023
ade5819
handle :assoc field type with :one amd :many cardinality
Tamara-Adeeb Apr 13, 2023
043bfe2
fix failed Compilation due to warning: variable data is unused
Tamara-Adeeb Apr 13, 2023
6d6cb78
add tests for rendering hidden inputs for custom type field
woylie Oct 9, 2022
26e3300
finish implementation of hidden input name
Dec 7, 2022
16f0101
remove dbg
woylie Mar 16, 2023
4cd2ae4
fixing docs
atomkirk Dec 8, 2023
c9e1a1d
Merge pull request #2 from woylie/fix-get-type
woylie Feb 20, 2024
84a7da8
Merge pull request #3 from woylie/hidden-input-for-type
woylie Feb 20, 2024
01afba5
update credo to 1.7.4
woylie Feb 20, 2024
f527e9d
update dependencies
woylie Feb 20, 2024
048313e
fix warnings, rename variables
woylie Feb 20, 2024
0693a57
update phoenix_html to 4.0.0
woylie Feb 20, 2024
eea054f
address credo warnings
woylie Feb 20, 2024
a94a1fd
update credo config
woylie Feb 20, 2024
094defc
refactor
woylie Feb 20, 2024
c6afd6f
update CI workflow
woylie Feb 20, 2024
9bf9377
Merge pull request #4 from woylie/phoenix-4.0
woylie Feb 20, 2024
c97e486
update GH actions
woylie Feb 20, 2024
33669dc
Merge pull request #5 from woylie/ci-versions
woylie Feb 20, 2024
b1869d6
Merge pull request #93 from woylie/master
mathieuprog Apr 25, 2024
fe99d51
Bump version to 3.0.6
mathieuprog Apr 25, 2024
d306ac5
Merge pull request #88 from atomkirk/patch-1
mathieuprog Apr 25, 2024
193829f
Merge pull request #80 from Elmseld/master
mathieuprog Apr 25, 2024
ec533c6
Update deps
mathieuprog May 25, 2024
08505d0
Update deps
mathieuprog May 25, 2024
1bcb680
Update deps
mathieuprog May 25, 2024
7192640
Update tests for phoenix_ecto 4.4 -> 4.5+ upgrade
mathieuprog May 25, 2024
b573058
Run mix format
mathieuprog May 25, 2024
e351580
Avoid compile-time dependencies between parent and
mathieuprog May 25, 2024
ad450b6
Run mix format
mathieuprog May 25, 2024
8dcf760
Bump version to 3.0.7
mathieuprog May 25, 2024
60058ba
Remove unnecessary config value
mathieuprog May 25, 2024
529a0e9
Update test support modules
mathieuprog May 25, 2024
6d3561a
Remove unused changeset function
mathieuprog May 25, 2024
b6954da
Fix license id
mathieuprog May 25, 2024
512d6bf
Update version matrix
mathieuprog May 25, 2024
9bc13e2
Support updating while retaining ids
mathieuprog May 25, 2024
6681c06
Make it work for embeds without ids
mathieuprog May 25, 2024
99ee346
Update Changelog
mathieuprog May 25, 2024
7fc853b
Handle form for list of embeds
mathieuprog May 26, 2024
c0f759d
Improve test readability
mathieuprog May 26, 2024
8fb5dfb
Remove support for custom changeset through MFA
mathieuprog May 26, 2024
5fd3bc9
Remove unnecessary test
mathieuprog May 26, 2024
4e79485
Fix hidden input field name
mathieuprog May 26, 2024
9630814
Remove unused variable
mathieuprog May 26, 2024
aeabe37
Fix docs
mathieuprog May 26, 2024
9814dfd
Support sort_ and drop_param for list of embeds
mathieuprog May 26, 2024
9bd8345
Allow lazy loading of default_type_on_sort_create
mathieuprog May 26, 2024
c13f124
Add PolymorphicEmbed.HTML.Component + restructure
mathieuprog May 26, 2024
4143842
Fix traverse_errors
mathieuprog May 26, 2024
92cecb3
Test travers_errors
mathieuprog May 26, 2024
3487808
Fix warnings
mathieuprog May 26, 2024
51d8826
Update deps
mathieuprog May 26, 2024
c4295c6
Bump version to 4.0.0
mathieuprog May 26, 2024
d7cc56c
Update gitignore
mathieuprog May 27, 2024
06a2425
Add retain_unlisted_types_on_load and
mathieuprog May 27, 2024
cce0c49
Document options to prevent errors on loading
mathieuprog May 27, 2024
c86b5b6
Update Changelog
mathieuprog May 27, 2024
2ec6292
Fix for MongoDB
mathieuprog May 27, 2024
cc5ca33
Update Changelog
mathieuprog May 27, 2024
0cdcdd0
Update license
mathieuprog May 27, 2024
94a8ed2
Update readme
mathieuprog May 27, 2024
74d5cd9
Update changelog
mathieuprog May 27, 2024
4bd7f1c
Update readme
mathieuprog May 27, 2024
a7d84b9
Document sort_param and drop_param
mathieuprog May 27, 2024
634c9cf
Document polymorphic_embed_inputs_for/1
mathieuprog May 27, 2024
39caf97
Add @type t() :: any()
kirillrogovoy May 27, 2024
3b04803
Merge pull request #96 from kirillrogovoy/patch-1
mathieuprog May 27, 2024
45b8236
add live_view as optional dependency
SteffenDE May 27, 2024
c8d3d2e
Merge pull request #97 from SteffenDE/optional_phoenix_live_view
mathieuprog May 27, 2024
1c2f3a5
Fix
mathieuprog May 28, 2024
76aeaf2
Add missing casts in support schema
mathieuprog May 28, 2024
605523b
Update gitignore
mathieuprog May 31, 2024
41a23cc
Add Form.source_data/1 and Form.source_module/1
mathieuprog May 31, 2024
a91ca55
Run mix format
mathieuprog May 31, 2024
619cf85
Update deps
mathieuprog May 31, 2024
76d22cf
Bump version to 4.1.0
mathieuprog May 31, 2024
58eedd4
Renaming
mathieuprog Jun 2, 2024
8b9ff8a
Document PolymorphicEmbed.get_polymorphic_module/3
mathieuprog Jun 2, 2024
945861d
Rename :type_field to :type_field_name
mathieuprog Jun 3, 2024
fe3becc
Bump version to 4.1.1
mathieuprog Jun 3, 2024
6b74a27
Update readme
mathieuprog Jun 3, 2024
744912e
Replace :type_field by :type_field_name in tests
mathieuprog Jun 3, 2024
0339c86
Clean
mathieuprog Jun 3, 2024
7d1ee14
Update README.md
mathieuprog Jun 3, 2024
d48d8bf
Improve options validation
mathieuprog Jun 5, 2024
c57a335
Remove unused attribute
mathieuprog Jun 5, 2024
e022fad
Add :use_parent_field_for_type option
mathieuprog Jun 8, 2024
75b7d84
Use Attrs
mathieuprog Jun 8, 2024
a74f12f
Simplify get_field_opts
mathieuprog Jun 8, 2024
cac49d7
Update Attrs
mathieuprog Jun 8, 2024
b9b3145
Add nil check to cast_polymorphic_embeds_many
clinejj Jul 17, 2024
6c4c080
Add test
clinejj Jul 17, 2024
cef782e
optional set list_data_for_field
clinejj Jul 18, 2024
68e54e0
Merge pull request #106 from clinejj/patch-1
mathieuprog Jul 18, 2024
996d40c
update Ecto to 3.12
Gladear Aug 13, 2024
a92bea8
use Ecto's new `:parametrized` representation
Gladear Aug 13, 2024
793aece
update changelog
Gladear Aug 13, 2024
4fb24f6
Merge pull request #109 from Gladear/fix-with-ecto-3.12
mathieuprog Aug 18, 2024
7a9d81e
Merge branch 'master' of github.com:mathieuprog/polymorphic_embed
mathieuprog Aug 19, 2024
8c874fe
Run mix format
mathieuprog Aug 19, 2024
26d4421
Update deps
mathieuprog Aug 19, 2024
324b731
Bump version to 5.0.0
mathieuprog Aug 19, 2024
8643475
implement failing test
nduitz Dec 5, 2024
16c5b55
fix
nduitz Dec 5, 2024
c9ce38c
bump liveview version
alinmarsh Dec 19, 2024
5713d6c
Merge pull request #118 from TernSystems/try-bump-dependencies
mathieuprog Dec 19, 2024
2bbfe91
relax phoenix_live_view version constraint
tfiedlerdejanze Feb 17, 2025
c628c1c
Merge pull request #120 from tfiedlerdejanze/patch-1
mathieuprog Feb 18, 2025
cf655e5
Bump version to 5.0.1
mathieuprog Feb 18, 2025
a13ba90
Make "mix test" completely quiet
whatyouhide Feb 18, 2025
e84dea0
Merge pull request #121 from mathieuprog/al/quiet-tests
mathieuprog Feb 18, 2025
222163f
Remove warning when aliases cannot be expanded
Mar 5, 2025
a896e4e
Merge pull request #123 from naserca/remove-alias-expansion-warning
mathieuprog Mar 6, 2025
8e2163c
Bump version to 5.0.2
mathieuprog Mar 6, 2025
d7f307b
Update CHANGELOG
whatyouhide Mar 6, 2025
13f816a
Update Elixir requirement to 1.13+
whatyouhide Mar 10, 2025
e770479
Merge pull request #124 from mathieuprog/al/ci
mathieuprog Mar 30, 2025
18a506d
Bump version to 5.0.3
mathieuprog Mar 30, 2025
d836583
Remove :preferred_cli_env deprecation in Elixir v1.19
san650 Dec 3, 2025
7a47ca9
Update credo from v1.0.1 to v1.1.1
san650 Dec 3, 2025
78828fa
Add elixir 1.19 to CI matrix
san650 Dec 3, 2025
bde243b
Fix CondClauseError when using use_parent_field_for_type with matching
zacksiri Dec 18, 2025
f39df20
Add test case
zacksiri Dec 18, 2025
662b312
Merge pull request #138 from zacksiri/master
mathieuprog Dec 21, 2025
e7bf5f0
Bump version to 5.0.4
mathieuprog Dec 21, 2025
fae4db0
Merge branch 'master' of github.com:mathieuprog/polymorphic_embed
mathieuprog Dec 21, 2025
875d948
Bump version to 5.0.5
mathieuprog Dec 21, 2025
2eefcfd
Update credo
mathieuprog Dec 21, 2025
17b5c76
Merge pull request #136 from san650/fix-preferred-cli-env-deprecation
mathieuprog Dec 21, 2025
ebe5ef0
fix warning
woylie Jan 6, 2026
4ecac6a
Merge pull request #140 from woylie/fix/warnings
mathieuprog Jan 6, 2026
2c7b9d4
Bump version to 5.0.6
mathieuprog Jan 6, 2026
6aa26ed
Merge pull request #115 from nduitz/fix-nested-embeds-errors
mathieuprog Mar 10, 2026
398442b
Merge upstream mathieuprog/polymorphic_embed v5.0.6
MajdSehwail Aug 4, 2026
de0f6cb
Add the traverse_errors/4 hook for parameterized types
MajdSehwail Aug 4, 2026
64bffc2
Add a guard for wrong-shaped cast params
MajdSehwail Aug 4, 2026
83ff505
Update locked dependencies to pass the Hex audit
MajdSehwail Aug 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions .credo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@
#
{Credo.Check.Design.AliasUsage,
[priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
{Credo.Check.Design.TagFIXME, []},
# You can also customize the exit_status of each check.
# If you don't want TODO comments to cause `mix credo` to fail, just
# set this value to 0 (zero).
#
{Credo.Check.Design.TagTODO, [exit_status: 2]},
{Credo.Check.Design.TagFIXME, []},

#
## Readability Checks
Expand All @@ -99,7 +99,7 @@
{Credo.Check.Readability.LargeNumbers, []},
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]},
{Credo.Check.Readability.ModuleAttributeNames, []},
{Credo.Check.Readability.ModuleDoc, []},
{Credo.Check.Readability.ModuleDoc, false},
{Credo.Check.Readability.ModuleNames, []},
{Credo.Check.Readability.ParenthesesInCondition, []},
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []},
Expand All @@ -122,32 +122,35 @@
{Credo.Check.Refactor.Apply, []},
{Credo.Check.Refactor.CondStatements, []},
{Credo.Check.Refactor.CyclomaticComplexity, []},
{Credo.Check.Refactor.FilterCount, []},
{Credo.Check.Refactor.FilterFilter, []},
{Credo.Check.Refactor.FunctionArity, []},
{Credo.Check.Refactor.LongQuoteBlocks, []},
{Credo.Check.Refactor.MatchInCondition, []},
{Credo.Check.Refactor.MapJoin, []},
{Credo.Check.Refactor.MatchInCondition, []},
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
{Credo.Check.Refactor.Nesting, []},
{Credo.Check.Refactor.RedundantWithClauseResult, []},
{Credo.Check.Refactor.RejectReject, []},
{Credo.Check.Refactor.UnlessWithElse, []},
{Credo.Check.Refactor.WithClauses, []},
{Credo.Check.Refactor.FilterFilter, []},
{Credo.Check.Refactor.RejectReject, []},
{Credo.Check.Refactor.RedundantWithClauseResult, []},

#
## Warnings
#
{Credo.Check.Warning.ApplicationConfigInModuleAttribute, []},
{Credo.Check.Warning.BoolOperationOnSameValues, []},
{Credo.Check.Warning.Dbg, []},
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
{Credo.Check.Warning.IExPry, []},
{Credo.Check.Warning.IoInspect, []},
{Credo.Check.Warning.MissedMetadataKeyInLoggerConfig, []},
{Credo.Check.Warning.OperationOnSameValues, []},
{Credo.Check.Warning.OperationWithConstantResult, []},
{Credo.Check.Warning.RaiseInsideRescue, []},
{Credo.Check.Warning.SpecWithStruct, []},
{Credo.Check.Warning.WrongTestFileExtension, []},
{Credo.Check.Warning.UnsafeExec, []},
{Credo.Check.Warning.UnusedEnumOperation, []},
{Credo.Check.Warning.UnusedFileOperation, []},
{Credo.Check.Warning.UnusedKeywordOperation, []},
Expand All @@ -156,11 +159,12 @@
{Credo.Check.Warning.UnusedRegexOperation, []},
{Credo.Check.Warning.UnusedStringOperation, []},
{Credo.Check.Warning.UnusedTupleOperation, []},
{Credo.Check.Warning.UnsafeExec, []}
{Credo.Check.Warning.WrongTestFileExtension, []}
],
disabled: [
#
# Checks scheduled for next check update (opt-in for now, just replace `false` with `[]`)
# Checks scheduled for next check update (opt-in for now)
{Credo.Check.Refactor.UtcNowTruncate, []},

#
# Controversial and experimental checks (opt-in, just move the check to `:enabled`
Expand All @@ -175,6 +179,8 @@
{Credo.Check.Readability.ImplTrue, []},
{Credo.Check.Readability.MultiAlias, []},
{Credo.Check.Readability.NestedFunctionCalls, []},
{Credo.Check.Readability.OneArityFunctionInPipe, []},
{Credo.Check.Readability.OnePipePerLine, []},
{Credo.Check.Readability.SeparateAliasRequire, []},
{Credo.Check.Readability.SingleFunctionToBlockPipe, []},
{Credo.Check.Readability.SinglePipe, []},
Expand All @@ -189,6 +195,7 @@
{Credo.Check.Refactor.MapMap, []},
{Credo.Check.Refactor.ModuleDependencies, []},
{Credo.Check.Refactor.NegatedIsNil, []},
{Credo.Check.Refactor.PassAsyncInTestCases, []},
{Credo.Check.Refactor.PipeChainStart, []},
{Credo.Check.Refactor.RejectFilter, []},
{Credo.Check.Refactor.VariableRebinding, []},
Expand Down
58 changes: 47 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: CI

env:
ELIXIR_VERSION: "1.16"
OTP_VERSION: "26"

on:
push:
branches:
Expand All @@ -11,14 +15,18 @@ on:
jobs:
test:
runs-on: ubuntu-latest
name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
name: Test OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
strategy:
matrix:
otp: ["24.3", "25.1"]
elixir: ["1.13", "1.14"]
exclude:
- otp: "25.1"
elixir: "1.13"
include:
- { elixir: 1.15, otp: 24 }
- { elixir: 1.15, otp: 25 }
- { elixir: 1.15, otp: 26 }
- { elixir: 1.16, otp: 24 }
- { elixir: 1.16, otp: 25 }
- { elixir: 1.16, otp: 26 }
- { elixir: 1.18, otp: 27 }
- { elixir: 1.19, otp: 27 }
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -37,21 +45,51 @@ jobs:
- 5432:5432

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
id: beam
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
- name: Restore dependencies and build cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
_build
deps
key: ${{ runner.os }}-otp-${{ steps.beam.outputs.otp-version }}-elixir-${{ steps.beam.outputs.elixir-version }}-mix-${{ hashFiles('mix.lock') }}
restore-keys: ${{ runner.os }}-otp-${{ steps.beam.outputs.otp-version }}-elixir-${{ steps.beam.outputs.elixir-version }}-
- name: Install Dependencies
run: |
mix local.rebar --force
mix local.hex --force
mix deps.get
- name: Run Tests
run: mix coveralls.github

lint:
runs-on: ubuntu-latest
name: Lint
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
id: beam
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION}}
- name: Restore dependencies and build cache
uses: actions/cache@v4
with:
path: |
_build
deps
key: ${{ runner.os }}-otp-${{ steps.beam.outputs.otp-version }}-elixir-${{ steps.beam.outputs.elixir-version }}-mix-${{ hashFiles('mix.lock') }}
restore-keys: ${{ runner.os }}-otp-${{ steps.beam.outputs.otp-version }}-elixir-${{ steps.beam.outputs.elixir-version }}-
- name: Restore PLT cache
uses: actions/cache@v3
uses: actions/cache@v4
id: plt_cache
with:
key: |
Expand All @@ -75,5 +113,3 @@ jobs:
run: mix hex.audit
- name: Generate docs
run: mix docs
- name: Run Tests
run: mix coveralls.github
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@ polymorphic_embed-*.tar

# Ignore Dialyzer plts file
.plts

.elixir_ls
.vscode

tmp.*
tmp/
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,42 @@
# Changelog

## 5.0.2

* Remove warning when aliases cannot be expanded (#123).

## 5.0.1

* Relax `phoenix_live_view` constraint to allow 1.0.

## 5.0.x

* Fix usage with Ecto 3.12. Require Ecto 3.12 or later
* Allow inferring type from parent field via new :use_parent_field_for_type option

## 4.1.x

* Add `Form.source_data/1` and `Form.source_module/1` (`get_polymorphic_type/2` doesn't work for list of embeds)
* Add `:retain_unlisted_types_on_load` and `:nilify_unlisted_types_on_load` options
* MongoDB fix
* Deprecate `:type_field` in favor of `:type_field_name`

## 4.0.x

* Support `sort_param` and `drop_param` for list of embeds
* Add `PolymorphicEmbed.HTML.Component.polymorphic_embed_inputs_for/1`
(similar to `Phoenix.Component.inputs_for/1`)
* Support updating list of embeds while retaining ids
* Fix form input rendering for list of embeds
* Fix `traverse_errors` for nested embeds

**Breaking Change**: The form helper `get_polymorphic_type/3` has been updated to `get_polymorphic_type/2`.
The module name parameter (previously the second parameter) has been removed.

## 3.0.x

* Default value for polymorphic list of embeds is `[]` instead of `nil` (following `embeds_many/3`)
* Support Phoenix HTML 4.0
* Avoid compile-time dependencies between parent and polymorphic embedded schemas

### Migration from 2.x to 3.x

Expand Down
14 changes: 0 additions & 14 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,3 @@
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

Copyright 2020 Mathieu Decaffmeyer

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Loading
Loading