Description
Hi,
I'm using spring-data-r2dbc
and the extension mechanism from r2dbc-postgresql
to create a codec for a custom Postgres range type:
CREATE TYPE timetzrange AS RANGE (subtype = timetz);
Since there's no native support for Postgres range types on Java's side, I created my own class OffsetTimeRange
, and registered a custom codec OffsetTimeRangeCodec
which implements the interface Codec<OffsetTimeRange>
.
So far, that worked perfectly fine, but I wanted to add the custom codec for its corresponding multirange type. From Postgres range types documentation, we know that:
When you define your own range you automatically get a corresponding multirange type.
So I registered another codec OffsetTimeRangeArrayCodec
which implements the interface Codec<OffsetTimeRange[]>
, but this raised the following exception upon reading/writing from the database:
java.lang.IllegalArgumentException: Unsupported array type: com.example.util.OffsetTimeRange
The problem
I did some debugging, and I found the exception is thrown in the following check (line #164):
The problem seems to be that the this.simpleTypeHolder.isSimpleType(typeToUse)
method checks against the local simple types, which are missing any type introduced by a custom codec.
As always, I'll be happy to help with a PR if someone can point me in the right direction 🙂
Cheers!