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

If use Torch.Pagination in top of Module compilation failed #458

Closed
GoddessEyes opened this issue May 6, 2024 · 4 comments · Fixed by #461, #462 or #463
Closed

If use Torch.Pagination in top of Module compilation failed #458

GoddessEyes opened this issue May 6, 2024 · 4 comments · Fixed by #461, #462 or #463

Comments

@GoddessEyes
Copy link

In top:

defmodule Sm.Librarium.Tools do
  use Torch.Pagination, repo: Sm.Repo, model: Sm.Librarium.Tools.ToolType, name: :librarium_tool_type
  import Ecto.Query, warn: false

Output:

iex -S mix phx.server

error: misplaced operator ^Torch.Helpers.sort(params)

  The pin operator ^ is supported only inside matches or inside custom macros. Make sure you are inside a match or all necessary macros have been required
  │
6 │   use Torch.Pagination, repo: Sm.Repo, model: Sm.Librarium.Tools.ToolType, name: :librarium_tool_type
  │   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  │
  └─ lib/sm/librarium/tools.ex:6: Sm.Librarium.Tools.do_paginate_librarium_tool_type/2

Change place:

defmodule Sm.Librarium.Tools do
 import Ecto.Query, warn: false
 use Torch.Pagination, repo: Sm.Repo, model: Sm.Librarium.Tools.ToolType, name: :librarium_tool_type

Output

Compiling 1 file (.ex)
[info] Running SmWeb.Endpoint with Bandit 1.5.0 at 127.0.0.1:4000 (http)
[info] Access SmWeb.Endpoint at http://localhost:4000
@GoddessEyes
Copy link
Author

Problem in torch/pagination.ex:144

        |> Filtrex.query(filter)
        |> order_by(^Torch.Helpers.sort(params))   <----
        |> Torch.Helpers.paginate(unquote(repo), params, pagination)

@cpjolicoeur
Copy link
Member

@GoddessEyes please let us know which version of Elixir and OTP you are running

@GoddessEyes
Copy link
Author

❯ elixir -v
Erlang/OTP 26 [erts-14.1.1] [source] [64-bit] [smp:32:32] [ds:32:32:10] [async-threads:1] [jit:ns]

Elixir 1.16.2 (compiled with Erlang/OTP 24)

@cpjolicoeur
Copy link
Member

@GoddessEyes Version 5.3.1 of Torch has been released to hex.pm to address this issue. Thanks for bringing it to our attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants