如何在IHP中向`sqlQuery “…WHERE x IN ?”`中传递值?

huangapple go评论73阅读模式
英文:

How do I pass values to a `sqlQuery "…WHERE x IN ?"` in IHP?

问题

我已经尝试过以下内容:

users :: [Users] <- sqlQuery "SELECT * FROM users u … WHERE u.id IN ?" (userIds :: [Id User])

以及 (Only userIds)(In userIds),但没有成功。我在文档中找不到任何示例。

英文:

I've tried

users :: [Users] &lt;- sqlQuery &quot;SELECT * FROM users u … WHERE u.id IN ?&quot; (userIds :: [Id User])

and (Only userIds) and (In userIds) but no success. I can't find any examples in the docs.

答案1

得分: 2

我猜它在底层使用了 postgres-simple,https://hackage.haskell.org/package/postgresql-simple-0.6.5/docs/Database-PostgreSQL-Simple.html#g:6 给出了答案:

users :: [Users] <- sqlQuery "SELECT * FROM users u … WHERE u.id IN ?" (Only (In userIds))
英文:

I guess it's using postgres-simple under the hood, https://hackage.haskell.org/package/postgresql-simple-0.6.5/docs/Database-PostgreSQL-Simple.html#g:6 gave the answer:

users :: [Users] &lt;- sqlQuery &quot;SELECT * FROM users u … WHERE u.id IN ?&quot; (Only (In userIds))

huangapple
  • 本文由 发表于 2023年6月19日 20:49:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76506795.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定