However, this library is still on ecto 3.11. So using this feature throws an error when attempting to preload an association on a polymorphic embedded schema -
[error] Task #PID<0.751.0> started from #PID<0.749.0> terminating
** (ArgumentError) cannot load `"02256ee1-fe8d-489d-b98d-fbbdf3168fe1"` as type :id for field `upload_id` in schema AudioField
(ecto 3.11.2) lib/ecto/schema/loader.ex:76: anonymous fn/5 in Ecto.Schema.Loader.unsafe_load/4
(elixir 1.16.3) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
(polymorphic_embed 4.1.1) lib/polymorphic_embed.ex:485: PolymorphicEmbed.do_load/3
(ecto 3.11.2) lib/ecto/type.ex:935: Ecto.Type.process_loaders/3
(ecto 3.11.2) lib/ecto/repo/queryable.ex:423: Ecto.Repo.Queryable.struct_load!/6
(ecto 3.11.2) lib/ecto/repo/queryable.ex:246: anonymous fn/5 in Ecto.Repo.Queryable.preprocessor/3
(elixir 1.16.3) lib/enum.ex:1700: Enum."-map/2-lists^map/1-1-"/2
(ecto 3.11.2) lib/ecto/repo/queryable.ex:237: Ecto.Repo.Queryable.execute/4
(ecto 3.11.2) lib/ecto/repo/queryable.ex:19: Ecto.Repo.Queryable.all/3
(ecto 3.11.2) lib/ecto/repo/preloader.ex:284: Ecto.Repo.Preloader.fetch_query/8
(elixir 1.16.3) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2
(elixir 1.16.3) lib/task/supervised.ex:36: Task.Supervised.reply/4
Function: &:erlang.apply/2
Args: [#Function<10.81589436/1 in Ecto.Repo.Preloader.maybe_pmap/3>, [#Function<21.81589436/1 in Ecto.Repo.Preloader.prepare_queries/6>]]
** (EXIT from #PID<0.749.0>) shell process exited with reason: an exception was raised:
** (ArgumentError) cannot load `"02256ee1-fe8d-489d-b98d-fbbdf3168fe1"` as type :id for field `upload_id` in schema AudioField
(ecto 3.11.2) lib/ecto/schema/loader.ex:76: anonymous fn/5 in Ecto.Schema.Loader.unsafe_load/4
(elixir 1.16.3) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
(polymorphic_embed 4.1.1) lib/polymorphic_embed.ex:485: PolymorphicEmbed.do_load/3
(ecto 3.11.2) lib/ecto/type.ex:935: Ecto.Type.process_loaders/3
(ecto 3.11.2) lib/ecto/repo/queryable.ex:423: Ecto.Repo.Queryable.struct_load!/6
(ecto 3.11.2) lib/ecto/repo/queryable.ex:246: anonymous fn/5 in Ecto.Repo.Queryable.preprocessor/3
(elixir 1.16.3) lib/enum.ex:1700: Enum."-map/2-lists^map/1-1-"/2
(ecto 3.11.2) lib/ecto/repo/queryable.ex:237: Ecto.Repo.Queryable.execute/4
(ecto 3.11.2) lib/ecto/repo/queryable.ex:19: Ecto.Repo.Queryable.all/3
(ecto 3.11.2) lib/ecto/repo/preloader.ex:284: Ecto.Repo.Preloader.fetch_query/8
(elixir 1.16.3) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2
(elixir 1.16.3) lib/task/supervised.ex:36: Task.Supervised.reply/4
Hm this may not be related to the Ecto version after all. I tried to fork and solve solve it, but it does not seem to work. Will close because it is probably not an issue with the library as I initially thought.
Ecto has added the ability for an embedded schema to preload associations in version 3.5.
However, this library is still on ecto
3.11
. So using this feature throws an error when attempting to preload an association on a polymorphic embedded schema -