Hi, I'm stuck with building out a library for a ne...
# exposed
l
Hi, I'm stuck with building out a library for a new type. I'm using https://github.com/pksunkara/pgx_ulid to introduce the ULID data type into Postgres. As such, I'm building out a small library to enable the ULID data type within Exposed, provided that you have this Postgres extension. My implementation is similar to the one used for exposed-json. However, I'm stuck with an error:
org.postgresql.util.PSQLException: ERROR: column "id" is of type ulid but expression is of type character varying
I discovered that this is because, with prepared statements, the parameter is treated as a varchar instead of the ULID type. The easiest way to resolve this would be to cast the parameter as a ULID. I see in the code, particularly in PostgreSQL.kt, that there is some code to cast JSONB appropriately. However, I am not sure how I would do this for my new ULID type. Is there any standardized way to ensure that Exposed will add a cast to my ULID type? If not, may I have guidance on how to best go about doing this? Thanks.
Fixed it. I moved the code to check for Postgres dialect from
setParameter
to
notNullValueToDB
, and set the type there. Exposed handled the rest.