Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression w/ multiple sorts #67

Closed
frankdugan3 opened this issue Jul 22, 2021 · 1 comment
Closed

Regression w/ multiple sorts #67

frankdugan3 opened this issue Jul 22, 2021 · 1 comment
Labels
bug Something isn't working needs review

Comments

@frankdugan3
Copy link
Contributor

Describe the bug
There seems to be a regression in sorting, where sorting on multiple columns crashes the query engine. It still does it even when sorting on multiple "normal" attributes and not loading any aggs/calcs. Seems to be a problem w/ any multiple-sorts.

All Ash libs are at the lastest as of this post:

* ash 1.46.13 (Hex package) (mix)
  locked at 1.46.13 (ash) 776a44f1
  ok
* ash_graphql 0.16.21 (Hex package) (mix)
  locked at 0.16.21 (ash_graphql) 23ef9737
  ok
* ash_phoenix 0.5.5 (Hex package) (mix)
  locked at 0.5.5 (ash_phoenix) 4a43ac09
  ok
* ash_policy_authorizer 0.16.2 (Hex package) (mix)
  locked at 0.16.2 (ash_policy_authorizer) 508a0c17
  ok
* ash_postgres 0.40.8 (Hex package) (mix)
  locked at 0.40.8 (ash_postgres) 91a832bb
  ok

Additional context
Here is the error output (the query is also paginated):

iex(4)> {:EXIT, #PID<0.1169.0>, :normal}
#Ash.Query<
  resource: Hsm.Attendance.Record,
  sort: [in: :asc, out: :asc],
  select: [:out, :in, :duration_hours, :notes]
>
[error] Task #PID<0.1172.0> started from #PID<0.1144.0> terminating
** (FunctionClauseError) no function clause matching in :lists.mapfoldl/3
    (stdlib 3.15.1) lists.erl:1357: :lists.mapfoldl(#Function<7.20389857/2 in Macro.do_traverse_args/4>, :ok, {:asc, {{:., [], [{:&, [], [0]}, :out]}, [], []}})
    (stdlib 3.15.1) lists.erl:1359: :lists.mapfoldl/3
    (elixir 1.12.2) lib/macro.ex:468: Macro.do_traverse/4
    (stdlib 3.15.1) lists.erl:1358: :lists.mapfoldl/3
    (elixir 1.12.2) lib/macro.ex:468: Macro.do_traverse/4
    (elixir 1.12.2) lib/macro.ex:463: Macro.do_traverse/4
    (stdlib 3.15.1) lists.erl:1358: :lists.mapfoldl/3
    (elixir 1.12.2) lib/macro.ex:468: Macro.do_traverse/4
    (ecto 3.6.2) lib/ecto/query/inspect.ex:230: Inspect.Ecto.Query.expr/3
    (ecto 3.6.2) lib/ecto/query/inspect.ex:195: Inspect.Ecto.Query.window/2
    (elixir 1.12.2) lib/enum.ex:1582: Enum."-map/2-lists^map/1-0-"/2
    (ecto 3.6.2) lib/ecto/query/inspect.ex:96: Inspect.Ecto.Query.to_list/1
    (ecto 3.6.2) lib/ecto/query/inspect.ex:75: Inspect.Ecto.Query.to_string/1
    (ecto 3.6.2) lib/ecto/query/inspect.ex:138: Inspect.Ecto.Query.inspect_source/1
    (ecto 3.6.2) lib/ecto/query/inspect.ex:134: Inspect.Ecto.Query.bound_from/2
    (ecto 3.6.2) lib/ecto/query/inspect.ex:92: Inspect.Ecto.Query.to_list/1
    (ecto 3.6.2) lib/ecto/query/inspect.ex:75: Inspect.Ecto.Query.to_string/1
    (ecto 3.6.2) lib/ecto/exceptions.ex:77: Ecto.SubQueryError.exception/1
Function: #Function<14.23005548/0 in Ash.Actions.Read.fetch_count/7>
    Args: []
[error] GenServer #PID<0.1144.0> terminating
** (FunctionClauseError) no function clause matching in Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
    (elixir 1.12.2) lib/enum.ex:1704: Enum."-map_reduce/3-lists^mapfoldl/2-0-"(#Function<24.10667392/2 in Ecto.Query.Planner.prewalk/6>, 0, {:asc, {{:., [], [{:&, [], [0]}, :out]}, [], []}})
    (elixir 1.12.2) lib/enum.ex:1704: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
    (elixir 1.12.2) lib/enum.ex:1704: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
    (elixir 1.12.2) lib/enum.ex:1704: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
    (elixir 1.12.2) lib/enum.ex:2385: Enum."-reduce/3-lists^foldl/2-0-"/3
    (elixir 1.12.2) lib/enum.ex:2385: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto 3.6.2) lib/ecto/repo/queryable.ex:208: Ecto.Repo.Queryable.execute/4
    (ecto 3.6.2) lib/ecto/repo/queryable.ex:19: Ecto.Repo.Queryable.all/3
    (ash_postgres 0.40.8) lib/data_layer.ex:435: AshPostgres.DataLayer.run_query/2
    (ash 1.46.13) lib/ash/actions/read.ex:780: Ash.Actions.Read.run_query/2
    (ash 1.46.13) lib/ash/actions/read.ex:482: anonymous fn/5 in Ash.Actions.Read.data_field/4
@frankdugan3 frankdugan3 added bug Something isn't working needs review labels Jul 22, 2021
@zachdaniel
Copy link
Contributor

Resolved in latest ash_postgres release :D Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs review
Projects
None yet
Development

No branches or pull requests

2 participants