PostgreSQL中IN和ANY运算符有什么区别?
两者的工作机制似乎是一样的.任何人都能用一个例子来解释这个吗
我正在尝试使用Ecto.Adapters.SQL.query,它工作正常,但不适用于数组。例如,此语句失败:
Ecto.Adapters.SQL.query Repo, "SELECT p.* FROM posts p WHERE p.title in ($1)",
[["title1", "title2"]]
Run Code Online (Sandbox Code Playgroud)
错误:
** (ArgumentError) Postgrex expected a binary that can be encoded/cast to
type "text", got ["title1", "title2"]. Please make sure the value you are
passing matches the definition in your table or in your query or convert
the value accordingly.
Run Code Online (Sandbox Code Playgroud)
更新
没有简单的方法可以做到,但这不是 Ecto 的限制,而是SQL 数据库 / PostgreSQL的限制,更多详细信息和解决方法。
很难相信在 2016 年 SQL 数据库仍然缺乏这样一个基本功能......