Package-level declarations

Types

Link copied to clipboard
data class DynamicDto(val typeName: String, val dataPayload: String)

The dynamic_dto composite in Kotlin: a discriminator and a JSON payload.

Link copied to clipboard
internal class DynamicRegistry

The dynamic_dto names a database knows and the class each stands for, attached to the driver's type catalog, since a discriminator stored in the data has to mean the same class to every client on the database. It is replaced and dropped with the catalog, and pinned for an execution with the converters reading it.

Link copied to clipboard
class DynamicTypes(client: OctaviusClient, val json: Json = octaviusJson, val strategy: DynamicWriteStrategy = DynamicWriteStrategy.AUTOMATIC_WHEN_UNAMBIGUOUS)

The dynamic_dto types this client knows: where they are registered, and where a value is wrapped for writing.

Link copied to clipboard

When an instance of a class registered as a dynamic type is written as a dynamic_dto without being wrapped.

Link copied to clipboard
internal class EnumAwareJson(base: Json)

The registered enums' serializers, as a module and as a Json with it folded in, resolved per conversion and rebuilt only when the registrations change. The driver replaces TypeCatalog.registeredEnums whole on every registration, so its identity is the version and checking it is a reference comparison.

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

Writes a registered enum into JSON under its PostgreSQL label, as the driver writes it in an enum column, and reads it back. Built from the registration, so an enum named at registerEnum and one found by @PgEnumType are covered alike.

Link copied to clipboard
internal class Registration<T : Any>(val name: String, val kClass: KClass<T>, serializer: KSerializer<T>, val json: EnumAwareJson, val strategy: DynamicWriteStrategy)

One class registered as a dynamic_dto, with the terms of the client that registered it: its values are written on strategy and through json whichever client runs the query.

Properties

Link copied to clipboard

The statements that create the dynamic_dto type and its constructors, harmless to run twice. Put them in a migration, or run them with DynamicTypes.install.

Functions

Link copied to clipboard
internal fun declaredTypeNameOf(kClass: KClass<*>): String

The discriminator kClass declares, for the overloads that take no name.