Here is my .iex.ex
file:
alias MyApp.Repo
alias MyApp.CMS
alias MyApp.CMS.Page
import Ecto.Query, only: [from: 2]
# import Ecto.Query
# import Ecto.Query, only: [from: 1]
Then, iex -S mix
Repo.all(from(Page))
** (CompileError) iex:1: undefined function from/1
but it works with
iex(1)> Repo.all(from(Page, []))
[debug] QUERY OK source="pages" db=5.0ms decode=5.1ms
SELECT p0."id", p0."body", p0."published_at", p0."title", p0."slug", p0."views", p0."author_id", p0."category_id", p0."inserted_at", p0."updated_at" FROM "pages" AS p0 []
[
%MyApp.CMS.Page{ ... },
%MyApp.CMS.Page{ ... }
]
With the full import of the Ecto.Query module in the .iex.ex
file, Repo.all(from(Page))
works.
Here comes the FIX
So finally I did import Ecto.Query, only: [from: 1]
and Repo.all(from(Page))
works.
However, when you look at the doc of Ecto.Query, there is no function from/1
.
Is it on purpose?
Is there a better way to use import only on functions with default argument ?
Tks ~