-
-
Notifications
You must be signed in to change notification settings - Fork 84
Closed
Description
Since polymorphic_embed 3.0.7 I get this warning:
[warning] Aliases could not be expanded for the given types in [MY STRUCT].
This likely means the types are defined using a module attribute or another reference
that cannot be expanded at compile time. As a result, this may lead to unnecessary
compile-time dependencies, causing longer compilation times and unnecessary
re-compilation of modules (the parent defining the embedded types).
Ensure that the types are specified directly within the macro call to avoid these issues,
or refactor your code to eliminate references that cannot be expanded.
I understand that I must refactor my code to avoid unnecessary compile-time dependencies but I'm not sure how.
Here is how I use polymorphic_embed with a fictional example:
defmodule MyApp.Reminder do
use Ecto.Schema
import Ecto.Changeset
import PolymorphicEmbed
alias MyApp.Reminder.Channels
schema "reminders" do
polymorphic_embeds_one :channel,
types: Channels.all(),
on_type_not_found: :raise,
on_replace: :update
end
end
defmodule MyApp.Reminder.Channels do
def all do
[
sms: MyApp.Channel.SMS,
email: MyApp.Channel.Email
]
end
endThe reason why we use a separate module to list all polymorphic_embed types is because we are using it in a lot of different schemas. Can I refactor my code while keeping a single source of truth with all types?
Metadata
Metadata
Assignees
Labels
No labels