Ecto.Query warning on compilation

I just got back to my Phoenix project after half a year absence, and my Elixir is a bit Rusty (mainly due to getting very exited after writing my first production app in Rust :stuck_out_tongue_winking_eye:)

Anyway, I got this simple query

  def list_cases do
    query = from case in Case,
      preload: [department: :court],
      preload: [:plaintiff, :defendant]
    Repo.all(query)
  end

And I get warning like this

warning: variable "case" does not exist and is being expanded to "case()", please use parentheses to remove the ambiguity or change the variable name

Am I doing something wrong, or is it due to how from dynamically composes actual SQL query? Is there something I can do to use “keyword queries”, as they are very readable, but get rid of those errors?

Did you import Ecto.Query in the module somewhere?

defmodule Office.Litigation do
  import Ecto.Query
  import Ecto.Changeset

  alias Office.Repo
  alias Office.Litigation.Case

  def list_cases do
    query = from case in Case,
      preload: [department: :court],
      preload: [:plaintiff, :defendant]
    Repo.all(query)
  end

  def change_case(%Case{} = case) do
      case
      |> Case.changeset()
      |> cast_assoc(:plaintiff)
      |> cast_assoc(:defendant)
      |> cast_assoc(:department)
  end
end

That’s how whole module looks actually. But I got other I think unrelated errors elsewhere, because I moved files around and try to extract clutter from controllers to context. I’ll get back to this, after I’ll fix those other errors.

A guess would be that since case is a reserved word, something weird is happening with compilation.

(so try using something other than case)

Oh, I first gone with c then changed to case. I’m guessing the issue is far deeper, but since I didn’t have time to fix all compilation errors yet, I have no idea what it may be. If I find the root cause, I’ll write here, nevertheless I thank you all for all ideas :slight_smile: