Closed dbernheisel closed 5 years ago
This warning is still occurring with 0.11.1
.
It looks like this comment in arc_ecto may not be correct, and thus it's related code is not correct: https://github.com/stavro/arc_ecto/blob/master/lib/arc_ecto/schema.ex#L20
# Cast supports both atom and string keys, ensure we're matching on both.
@OvermindDL1 what's your changeset logic look like? I've been using 0.11.1
and haven't seen the warnings lately.
Mine looks something like this:
@required_fields ~w(first_name last_name)a
@optional_fields ~w(user_id company phone job_title linkedin_url job_description supervisor_name other)a
@doc false
def changeset(struct, attrs) do
struct
|> cast(attrs, @required_fields ++ @optional_fields)
|> ensure_uuid(:id)
|> cast_attachments(attrs, [:avatar, :other_file, :job_description_file])
|> ...
Figured out the reason, it was caused by having the file field in the cast
instead of cast_attachments
(perhaps an error should be thrown instead when that is done, easy to detect because scope
is nil
).
When using Ecto 3.0 and arc_ecto, I see a lot of warnings about arc_ecto passing strings into
cast()
as the allowed list of param keys.Here are the ecto versions in my mix.lock