Pattern match on order_by inside ecto query

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.


According to the docs of Ecto.Query.t the fields name is :order_bys.