I was trying to change the select
value from a map to a keyword, and I’m getting an error I don’t understand.
== Compilation error in file lib/enaia/emails/email_autocomplete.ex ==
** (Ecto.Query.CompileError) Cannot mix fields with interpolations, such as: `select: [:foo, ^:bar, :baz]`. Instead interpolate all fields at once, such as: `select: ^[:foo, :bar, :baz]`. Got: [
email: ce.address,
is_primary: fragment("COALESCE(?, FALSE)", d.primary_contact_id == c.id),
is_point_of_contact: false
].
Code:
from c in Contact,
join: ce in ContactEmail,
on: ce.contact_id == c.id,
join: d in Deal,
on: d.id == c.deal_id,
where: c.deal_id == ^deal_id,
select: [
contact_type: c.contact_type,
email: ce.address,
is_primary: fragment("COALESCE(?, FALSE)", d.primary_contact_id == c.id),
is_point_of_contact: false
]
The “interpolation” seems to be is_point_of_contact: false
. If I remove that line, I no longer get the error. If I write it as is_point_of_contact: ^false
, I also do not get the error.
Can someone explain to me:
- Why I get the error in case of a Keyword, but not a Map?
- Why I’d need to use
^false
?
Thanks