When I use a variable instead of a string in the prefix option, the query fails:
The query:
query =
from u in User,
prefix: ^params["prefix"],
order_by: [asc: u.full_name, asc: u.id],
select: struct(u, [:id, :first_name, :last_name, :full_name])
Repo.all(query)
The result:
Ecto.Query.CompileError
prefix
must be a compile time string, got: params["prefix"]
When I use a string in the prefix option like:
query =
from u in User,
prefix: "tenant",
order_by: [asc: u.full_name, asc: u.id],
select: struct(u, [:id, :first_name, :last_name, :full_name])
Repo.all(query)
everything works fine.
So, how can I convert a string variable into a compile time string? Is this possible or is the problem a bug in ecto?
Thanks for your advice.