agentultra / postgresql-replicant

A streaming PostgreSQL logical replication client library for Haskell
BSD 3-Clause "New" or "Revised" License
38 stars 3 forks source link

Handle custom types #5

Closed agentultra closed 3 years ago

agentultra commented 3 years ago

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

agentultra commented 3 years ago

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.