nonNullTransform
Applies a special transformation that allows a nullable database column to be exposed as a non-nullable type on the Kotlin side.
This is the inverse of nullTransform, which maps a non-nullable DB column to a nullable Kotlin type.
The column remains nullable in the database schema. The transformation enables reflecting null values from the database as a concrete non-null value in Kotlin (e.g., an empty string, a default object, a sentinel value, etc.).
Sample:
object Users : Table() {
val description = text("description")
.nullable()
.nonNullTransform(
wrap = { it?.trim()?.ifEmpty { null } ?: "" },
unwrap = { if (it.isEmpty()) null else it }
)
}Return
A new column of type Wrapped (non-nullable) with the applied transformations.
Parameters
Type Parameters
The non-nullable type into which the value of the underlying column will be transformed.
The type of the original column (the non-null portion of the nullable column type).
Applies a special transformation that allows a nullable database column to be exposed as a non-nullable type on the Kotlin side.
This is the inverse of nullTransform, which maps a non-nullable DB column to a nullable Kotlin type.
The column remains nullable in the database schema. The transformation enables reflecting null values from the database as a concrete non-null value in Kotlin (e.g., an empty string, a default object, a sentinel value, etc.).
Return
A new column of type Wrapped (non-nullable) with the applied transformations.
Parameters
An instance of ColumnTransformer to handle the transformations. Its ColumnTransformer.wrap method must return a non-null value even when given null. Its ColumnTransformer.unwrap method may return null to store null in the database.
Type Parameters
The non-nullable type into which the value of the underlying column will be transformed.
The type of the original column (the non-null portion of the nullable column type).