Errors with pgocaml

PGOcaml makes a best effort to decode Postgres types, but those information_schema tables define their own types (information_schema.sql_identifier is the offender here I think) which PGOcaml doesn’t have built-in converter functions for. It’s actually possible to add extra type conversions, but there’s a much easier solution.

let res =
    [%pgsql.object
      dbh
        "select
          table_schema::text,
          table_name::text
         from information_schema.columns
         where table_schema not in ('information_schema', 'pg_catalog')
         order by table_schema, 
          table_name"]

Note the coercion to text - PGOcaml then just sees them as strings and can decode them without any trouble.

It’s the price you pay for being able to write typed SQL.