Search code examples
elixirectosubquery

Why am I getting "unsupported :except_all in keyword query expression" in my Elixir Ecto query?


This Ecto query works:

bid_players = from a in Auction,
                where: a.id == 1,
                join: bids in assoc(a, :bids),
                join: player in assoc(bids, :player),
                select: player.id

And this query works:

players = from player in Player,
            where: player.year_range == ^a.year_range,
            select: player.id

But I can't figure out how to get the players who are not bid players. When I try this:

not_bid_players = from player in Player,
                    where: player.year_range == ^a.year_range,
                    select: player.id,
                    except_all: ^bid_players

...I get:

** (Ecto.Query.CompileError) unsupported :except_all in keyword query expression
    (ecto) expanding macro: Ecto.Query.from/2
    iex:35: (file)

I guess there's something about except_all (see https://hexdocs.pm/ecto/Ecto.Query.html#except_all/2) that I don't understand.


Solution

  • except_all was added in Ecto 3.
    phoenix_ecto needs to be at 4.0 to use Ecto 3+, looks like you need to upgrade.