agentultra / postgresql-replicant

A streaming PostgreSQL logical replication client library for Haskell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle custom types

agentultra opened this issue · comments

It would be nice if there was a way to handle user-defined PostgreSQL types that map to Haskell ones such as enums into WalValue

If we have a table setup like this with a custom enumeration type:

create type foo as enum ('bar', 'baz', 'quz');

create table testing_types (
 id serial primary key,
 test foo not null
);

insert into testing_types (test) values ('bar');

We do receive the change with the Column type:

Change {changeNextLSN = LSN {filepart = 0, offset = 24033352}, changeDeltas = [WInsert (Insert {insertSchema = "public", insertTable = "testing_types", insertColumns = [Column {columnName = "id", columnType = "integer", columnValue = WalNumber 1.0},Column {columnName = "test", columnType = "foo", columnValue = WalString "bar"}]})]}

Which includes a string encoding of the name of the enumeration which would allow a user to parse the value.