deserialize

fun <T> deserialize(source: Any?, expectedType: KType, sourceType: PgType): T

Converts a decoded database value to expectedType.

A null source is returned as null when expectedType allows it. Where no converter claims the value, it is returned unchanged if it is already an instance of expectedType; otherwise this fails rather than casting blindly. What a converter produces is checked against expectedType too, so a converter that over-claims is named in the exception instead of surfacing as a ClassCastException in the caller's own frame.

Return

The converted value.

Parameters

source

The decoded value, or null for SQL NULL.

expectedType

The Kotlin type wanted, generic arguments included.

sourceType

The PostgreSQL type of the value.

Type Parameters

T

The type to return.

Throws

REQUIRED_ATTRIBUTE_MISSING if source is null and expectedType is not nullable, NO_CONVERTER_FOUND if nothing can produce expectedType, CONVERSION_ERROR if a converter failed or returned the wrong type.