Pattern matching is indeed a powerful feature that comes into handy quite often. When we have an ecto query we can pattern match on different methods like select
, distinct
.
def pattern_match(%{select: select} = query), do: query
def pattern_match(%{distinct: distinct} = query), do: query
This will return the underlying query or nil, but when I do order_by like this. Elixir raises no match of right-hand side error
.
def pattern_match(%{order_by: order} = query), do: query
I am wondering why I am not unable to fetch order_by
like this.
thanks.