sqlpostgresqlhaskellihp

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


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.


Solution

  • 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))