-
Notifications
You must be signed in to change notification settings - Fork 71
Description
Sometimes PostgreSQL gets confused about types if there's no explicit typing; I've noticed it with a non-empty array (PGArray) of enum elements, which gets recognized as text[] instead of user_role[] in my case. Setting types in queries explicitly is a bit cumbersome in some cases, and it would be handy if postgresql-simple facilitated it. For instance, the following works, but it uses Plain for something other than its intended purpose as it's described in the documentation (that is, it's a hack):
instance ToField Role where
toField r = Many [Escape $ BS8.pack $ show r, Plain ":: user_role"]Maybe something like a Typed Action String action constructor should be introduced, or the Plain description should be adjusted. It may be out of scope of postgresql-simple, but seems like ToField is the appropriate place for adding type information.