hasql icon indicating copy to clipboard operation
hasql copied to clipboard

Hasql.Encoders encodes composite types with UNKOWN instead of RECORD

Open AnthonySuper opened this issue 6 months ago • 2 comments

Currently, the function composite builds an encoder with an OID of unknown. This means that trying to bind composite arrays does not work, with the following error:

ResultError (ServerError "42804" "binary data has array element type 705 (unknown) instead of expected 2249 (record)" Nothing Nothing Nothing)

I believe that this can be fixed by using the record OID instead.

AnthonySuper avatar Sep 01 '25 16:09 AnthonySuper

You've correctly identified the problem. I am not sure that switching the type to record will help, but I will accept a PR, which proves that it works via tests.

In the long run I've been planning a solution that would look up the OID in the DB by name and cache it. Can't make promises how soon I'll get to it.

nikita-volkov avatar Sep 08 '25 04:09 nikita-volkov

The solution is in master. Custom types are identifiable by name now. I'm prepping the next major release.

nikita-volkov avatar Oct 26 '25 10:10 nikita-volkov

Hasql 1.10 contains the fix.

nikita-volkov avatar Jan 07 '26 17:01 nikita-volkov