I’m trying to query an array of strings using where in but I’m getting this strange error, I’m doing something wrong in the query?
** (Plug.Conn.WrapperError) ** (Ecto.Query.CastError) lib/api/article/list_articles.ex:25: value `["test", "tech"]` in `where` cannot be cast to type {:in, {:array, :string}} in query:
from a0 in Api.Articles.Article,
where: a0.keywords in ^["test", "tech"],
select: a0
my query
keywords = ["test", "tech"]
from(a in Article)
|> where([a], a.keywords in ^keywords)
|> Repo.all()
my schema
schema "articles" do
field :keywords, {:array, :string}
end
migration
alter table(:articles) do
add :keywords, {:array, :string}
end