postgresql - Using postgres-simple, how do I get multiple parameters from a row -
i trying make basic query postgresql-simple 0.5.0.1 , 0.5.1.0. familiar content in postgresql-simple query error, different error message.
data sensorrow = sensorrow int string string deriving show instance fromrow sensorrow fromrow = sensorrow <$> field <*> field <*> field *databaseintegrationspec> db <- connectpostgresql dbstring *databaseintegrationspec> r <- query_ db "select (id, name, token) sensor" :: io [sensorrow] *** exception: incompatible {errsqltype = "record", errsqltableoid = nothing, errsqlfield = "row", errhaskelltype = "int", errmessage = "types incompatible"} *databaseintegrationspec> r <- query_ db "select (id, name, token) sensor" :: io [(int, string, string)] *** exception: incompatible {errsqltype = "record", errsqltableoid = nothing, errsqlfield = "row", errhaskelltype = "int", errmessage = "types incompatible"} *databaseintegrationspec>
by reading of documentation , of example code, both of these queries should work. however, reading error message, errsqlfield
, appears in both cases library trying convert entire row int.
so, wrong here? have encountered bug in postgresql-simple library, , if so, how can work around it?
the entire problem lay in sql query. correct query use is:
*databaseintegrationspec> r <- query_ db "select id, name, token sensor" :: io [sensorrow]
in short, putting parenthesis around field names in query causes postgresql return things in format not know how decode.
Comments
Post a Comment