pgjdbc / r2dbc-postgresql

Postgresql R2DBC Driver
https://r2dbc.io
Apache License 2.0
1.01k stars 177 forks source link

Can't process CITEXT #488

Open tobq opened 2 years ago

tobq commented 2 years ago

In the passed, I had to register a custom codec to process the citext. Is there a reason the library doesn't handle citext itself?

One issue I found with my custom codec is that the OID isn't always the same - it was different on my local machine than to my server

Caused by: java.lang.IllegalArgumentException: Cannot decode value of type java.lang.Object with OID 16395
    at io.r2dbc.postgresql.codec.DefaultCodecs.decode(DefaultCodecs.java:180) ~[r2dbc-postgresql-0.8.10.RELEASE.jar:0.8.10.RELEASE]
tobq commented 2 years ago

I guess it could be argued that there's no appropriate (native) java type that can represent CITEXT, so the citext should be converted to a normal string before reaching the driver?

mp911de commented 2 years ago

citext seems an optional module. It would make sense to register a StringCodec for a given OID to be able to read such values as String. Take a look at https://github.com/pgjdbc/r2dbc-postgresql/blob/main/src/main/java/io/r2dbc/postgresql/codec/BuiltinDynamicCodecs.java.