TypeManager

class TypeManager(holder: CatalogHolder, searchPathProvider: () -> List<String> = { emptyList() })

Registers PostgreSQL types, codecs and converters, and reads back what is registered.

This class provides a high-level API over CatalogHolder, making it easier to register custom mappings between Kotlin types and PostgreSQL database types.

The reading half of it is TypeLookup, which this delegates to and which is what a conversion is handed: registration is reached from a session, not from inside a converter.

Constructors

Link copied to clipboard
internal constructor(holder: CatalogHolder, searchPathProvider: () -> List<String> = { emptyList() })

Properties

Link copied to clipboard

Everything the driver knows about this database: dictionaries, converters and registrations, as one value.

Link copied to clipboard

The dictionary maintaining TypeCodec implementations.

Link copied to clipboard

Factory for creating container types (like composites).

Link copied to clipboard

The dictionary mapping PostgreSQL type names to their OIDs and vice versa.

Link copied to clipboard
internal val lookup: TypeLookup

The reading half, following the store rather than any one catalog.

Functions

Link copied to clipboard
fun <T : Any> attach(type: KClass<T>, transform: (T?) -> T)

Keeps a value for this database under type, for a layer built on the driver whose registrations belong to the database rather than to any one session.

Link copied to clipboard

A lookup on the same database with no session behind it.

Link copied to clipboard
internal fun pinnedTo(catalog: TypeCatalog): TypeLookup

A lookup reading catalog and nothing else, for as long as it is held.

Link copied to clipboard
inline fun <T : Any> registerAutoComposite(typeName: String = "", schema: String = "")

Registers a composite type mapped reflectively onto the data class T.

fun registerAutoComposite(kClass: KClass<*>, typeName: String = "", schema: String = "")

Registers a composite type mapped reflectively onto the data class kClass.

Link copied to clipboard
fun registerCodec(codec: TypeCodec<*>)

Registers a custom TypeCodec for encoding and decoding database types at the lowest level.

Link copied to clipboard
inline fun <T : Enum<T>> registerEnum(typeName: String = "", schema: String = "", pgConvention: CaseConvention = CaseConvention.SNAKE_CASE_UPPER, kotlinConvention: CaseConvention = CaseConvention.PASCAL_CASE)
fun registerEnum(enumClass: KClass<*>, typeName: String = "", schema: String = "", pgConvention: CaseConvention = CaseConvention.SNAKE_CASE_UPPER, kotlinConvention: CaseConvention = CaseConvention.PASCAL_CASE)

Registers an enum type, creating both parameter and result converters.

Link copied to clipboard

Registers a custom ParameterConverter for mapping Kotlin types to PostgreSQL database types.

Link copied to clipboard

Registers a custom ResultConverter for mapping PostgreSQL database types to Kotlin types.

Link copied to clipboard
fun resolveOid(typeName: String, schema: String = "", isArray: Boolean = false): Int

Resolves an OID for a given type name, considering the current search path.