cannot use ^offset outside of match clauses
rafaeljesus opened this issue · 4 comments
rafaeljesus commented
Hi,
I am getting the error below
=> scrivener
Compiled lib/scrivener/page.ex
== Compilation error on file lib/scrivener.ex ==
** (CompileError) lib/scrivener.ex:152: cannot use ^offset outside of match clauses
(elixir) expanding macro: Kernel.|>/2
lib/scrivener.ex:155: Scrivener.entries/4
(elixir) expanding macro: Kernel.if/2
lib/scrivener.ex:147: Scrivener.entries/4
Here is my module
defmodule EventTrack.Event do
use Ecto.Schema
import Ecto.Query
import Ecto.Changeset
alias EventTrack.{Repo, Event}
def search(params \\ :empty) do
page = Event
|> where([e], e.name == ^params["name"])
|> order_by([e], desc: e.inserted_at)
|> Repo.paginate(params)
// omited
end
deps
{:ecto, "~> 1.0.7", override: true},
{:mongodb_ecto, "~> 0.1.4"},
{:scrivener, "~> 1.0"}
Thx
drewolson commented
@rafaeljesus Apologies, this was a regression against older versions of ecto (1.0.x
). I've pushed a new version, 1.2.0
, that should fix the problem.
rafaeljesus commented
No worries @drewolson
Upgrading to v-1.2.0 I get this
=> scrivener
Compiled lib/scrivener/config.ex
== Compilation error on file lib/scrivener.ex ==
** (Ecto.Query.CompileError) `count(field(m, ^primary_key), :distinct)` is not a valid query expression.
* If you intended to call a database function, please check the documentation
for Ecto.Query to see the supported database expressions
* If you intended to call an Elixir function or introduce a value,
you need to explicitly interpolate it with ^
expanding macro: Ecto.Query.select/3
lib/scrivener.ex:189: Scrivener.total_entries/2
(elixir) expanding macro: Kernel.|>/2
lib/scrivener.ex:190: Scrivener.total_entries/2
The code is here event_track
drewolson commented
Unfortunately, although ecto 1.0.x
supports count
and field
, there seems to be a bug around supporting dynamic fields inside of counts. I'm releasing 1.2.1
that only supports ecto ~>1.1
. This should be a backwards compatible upgrade of ecto for you.
rafaeljesus commented
Ok @drewolson thank you for your quick replies