PgEnumSerializer

internal class PgEnumSerializer(enumClass: KClass<*>, registration: PgEnumRegistration) : KSerializer<Any>

Writes a registered enum into JSON under the label PostgreSQL holds, and reads it back.

The driver's enum converters answer for an enum column; nothing about them reaches a value that travels as JSON instead, where kotlinx.serialization writes the Kotlin constant's own name. That leaves one value spelled two ways depending on where it is stored, and a query filtering on payload ->> 'office' matching neither reliably.

It is built from the registration and not from an annotation, so the enum named at registerEnum and the one a classpath scan found by @PgEnumType are covered alike: both arrive in the driver's registry the same way, carrying the conventions they were registered under.

Parameters

registration

What it was registered as, which is where the two conventions come from.

Constructors

Link copied to clipboard
constructor(enumClass: KClass<*>, registration: PgEnumRegistration)

Properties

Link copied to clipboard
open override val descriptor: SerialDescriptor

Functions

Link copied to clipboard
open override fun deserialize(decoder: Decoder): Any
Link copied to clipboard
open override fun serialize(encoder: Encoder, value: Any)