mongodb_ecto icon indicating copy to clipboard operation
mongodb_ecto copied to clipboard

`order_by` does not work with Ecto 3.12

Open sriedel opened this issue 11 months ago • 2 comments
trafficstars

Using ecto 3.12.5, attempting to sort the result of a query with the following query pipeline

iex(17)> TodoItem |> order_by(asc: :id) |> Repo.all

results in the error

** (FunctionClauseError) no function clause matching in anonymous fn/1 in Mongo.Ecto.NormalizedQuery.order/2

    The following arguments were given to anonymous fn/1 in Mongo.Ecto.NormalizedQuery.order/2:

        # 1
        %Ecto.Query.ByExpr{
          expr: [asc: {{:., [], [{:&, [], [0]}, :id]}, [], []}],
          file: "iex",
          line: 17,
          params: nil,
          subqueries: []
        }

    (mongodb_ecto 2.0.0-rc.2) lib/mongo_ecto/normalized_query.ex:772: anonymous fn/1 in Mongo.Ecto.NormalizedQuery.order/2

It seems the name of the Struct was changed from Query.QueryExpr to Query.ByExpr.

sriedel avatar Dec 15 '24 10:12 sriedel

@sriedel Sorry for the slow response! Great catch. @mweidner037 Could you take a look at the related PR?

scottmessinger avatar Jan 28 '25 19:01 scottmessinger

@sriedel We've run into this and are looking into it!

scottmessinger avatar Mar 07 '25 13:03 scottmessinger

@mweidner037 This was fixed in the most recent release, right?

scottmessinger avatar Oct 02 '25 19:10 scottmessinger

I believe so.

mweidner037 avatar Oct 02 '25 19:10 mweidner037