I was investigating a failure while working on a new feature in Ash. The code failed on a rather obscure point (a FunctionClauseError deep in Code.Normalizer). Ecto.Query.Planner was removing its portion of the stacktrace so I've started digging to find the cause of the error.
[expr: {:%{},[],[aggregates: {:%{},[],[aggregate_0: {:type,[],[{:coalesce,[],[{:type,[],[{{:.,[],[{:as,[],[1]},:aggregate_0]},[],[]},{:parameterized,Ash.Type.Integer.EctoType,[]}]},{:type,[],[{:^,[],[0]},{:parameterized,Ash.Type.Integer.EctoType,[]}]}]},{:parameterized,Ash.Type.Integer.EctoType,[]}]}]}]},pairs: [aggregates: {:%{},[],[aggregate_0: {:type,[],[{:coalesce,[],[{:type,[],[{{:.,[],[{:as,[],[1]},:aggregate_0]},[],[]},{:parameterized,Ash.Type.Integer.EctoType,[]}]},{:type,[],[{:^,[],[0]},{:parameterized,Ash.Type.Integer.EctoType,[]}]}]},{:parameterized,Ash.Type.Integer.EctoType,[]}]}]}],query: #Ecto.Query<from p0 in AshPostgres.Test.Post, as: 0,left_lateral_join: u1insubquery(fromu0inAshPostgres.Test.User,as: 0,join: p1inAshPostgres.Test.PostFollower,on: p1.follower_id==u0.id,where: type(type(as(0).is_active,{:parameterized,Ash.Type.Boolean.EctoType,[]})==type(^true,{:parameterized,Ash.Type.Boolean.EctoType,[]}),{:parameterized,Ash.Type.Boolean.EctoType,[]}),where: parent_as(0).id==p1.post_id,group_by: [p1.post_id],distinct: [asc: p1.post_id],select: %{post_id: map(p1,[:post_id]).post_id,aggregate_0:type(coalesce(count(type(as(0).id,{:parameterized,Ash.Type.UUID.EctoType,[]})),type(^0,{:parameterized,Ash.Type.Integer.EctoType,[]})),{:parameterized,Ash.Type.Integer.EctoType,[]})}),on: true,where: type(as(0).type,{:parameterized,Ash.Type.Atom.EctoType,[]})==type(^"sponsored",{:parameterized,Ash.Type.Atom.EctoType,[]}),where: p0.author_id==parent_as(0).id,windows: [order: [order_by: [asc: as(0).id]]],order_by: [asc: as(0).id],limit: ^2,select: merge(merge(struct(p0,[:id,:title,:datetime,:score,:public,:category,:type,:price,:decimal,:status,:status_enum,:status_enum_no_cast,:point,:composite_point,:stuff,:list_of_stuff,:uniq_one,:uniq_two,:uniq_custom_one,:uniq_custom_two,:list_containing_nils,:created_at,:updated_at,:organization_id,:author_id]),%{aggregates: %{aggregate_0:type(coalesce(type(as(1).aggregate_0,{:parameterized,Ash.Type.Integer.EctoType,[]}),type(^0,{:parameterized,Ash.Type.Integer.EctoType,[]})),{:parameterized,Ash.Type.Integer.EctoType,[]})}}),%{__order__: over(row_number(),:order)})>
]
Elixir version
1.16.2
Database and Version
PostgreSQL 15.4
Ecto Versions
master, commit a8cd6ac
Database Adapter and Versions (postgrex, myxql, etc)
Postgrex 0.17.5
Current behavior
I was investigating a failure while working on a new feature in Ash. The code failed on a rather obscure point (a
FunctionClauseErrordeep inCode.Normalizer).Ecto.Query.Plannerwas removing its portion of the stacktrace so I've started digging to find the cause of the error.The error bubbles up from the call to
Macro.to_string/1here.These are the arguments passed to the function (printed with
IO.inspect(binding()):This is the original stacktrace (without the filtering from
Ecto.Query.Planner:Expected behavior
Not sure if this is a problem in
Macro.to_stringor maybe in the original expression. The expected behavior is that raising an error should not to trigger another error obfuscating the original one (possibly even with malformed expressions).