Closed autcrock closed 8 years ago
Sure, the underscore in _int8
means it's an array of 8-byte integers. So you need to change the return type to [Only (Vector Int64)]
Or, don't call _array_agg
, which would probably be a somewhat better choice in this situation.
Thanks Leon, not only for the answer which worked, but for your work on postgresql-simple which I am finding very helpful.
The _array_agg will go away soon. It was a by product of my initial attempts to get the marshalling types correct.
You are welcome!
Looking at the Database.PostgreSQL.Simple.FromField
documentation, this isn't mentioned. So that is worth fixing.
Unfortunately the underscore meaning "array of" is a convention; I don't think it's a hard and fast rule. I know that some of the older built in types have an associated array type that doesn't start with an underscore. It's probably possible to create a non-array type that starts with an underscore as well. The more robust approach is checking the pg_type
table, which contains metadata for every type (built in or not)
Try this query in psql
: select oid, * from pg_type
; the partial contents of this metatable is also accessible through postgresql-simple's TypeInfo
system.
Thanks for that further information Leon.
I was the victim of ten years of C programming seeing the _ as an indicator of an internal type, managing to convince myself it was on the Haskell side, although I didn't see it as I skimmed through the postgres-simple source code.
Cheers
Mike Thomas
On Fri, Aug 5, 2016 at 10:54 PM, Leon P Smith notifications@github.com wrote:
Looking at the Database.PostgreSQL.Simple.FromField documentation, this isn't mentioned. So that is worth fixing.
Unfortunately the underscore meaning "array of" is a convention; I don't think it's a hard and fast rule. I know that some of the older built in types have an associated array type that doesn't start with an underscore. It's probably possible to create a non-array type that starts with an underscore as well. The more robust approach is checking the pg_type table, which contains metadata for every type (built in or not)
Try this query in psql: select oid, * from pg_type; the partial contents of this metatable is also accessible through postgresql-simple's TypeInfo https://hackage.haskell.org/package/postgresql-simple-0.5.2.1/docs/Database-PostgreSQL-Simple-TypeInfo.html system.
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/lpsmith/postgresql-simple/issues/190#issuecomment-237842748, or mute the thread https://github.com/notifications/unsubscribe-auth/AGUoMpWOMCwQX5JSH1ZkGR3foKnrZO7xks5qczKEgaJpZM4JcOnc .
Hi Leon.
I have reached the limit of my out-of-date Haskell debugging skills with this one, so reaching out for help.
http://stackoverflow.com/questions/38735008/haskell-postgresql-simple-incompatible-type-int8-and-int64-and-integer
Hopefully it is nothing more than a misapprehension of the documentation on my part.
Cheers
Mike Thomas