Ecto `select` clause: map vs keyword treated differently

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:

  1. Why I get the error in case of a Keyword, but not a Map?
  2. Why I’d need to use ^false?

Thanks

1 Like

I am not sure of the answer to your question, but are keyword lists actually supported in the select syntax? I ask because they are missing from the examples in the docs. If they are supported it would be nice if they were included there. I don’t think I’ve ever actually tried to select a KW list :slight_smile: