英文:
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] <- sqlQuery "SELECT * FROM users u … WHERE u.id IN ?" (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] <- sqlQuery "SELECT * FROM users u … WHERE u.id IN ?" (Only (In userIds))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论