forType

inline fun <reified T, reified R> forType(sqlTypeName: String, crossinline convert: (T) -> R)

Register a converter for every column with the given declared SQL type name.

Parameters

sqlTypeName

name of the declared SQL type (as written in CREATE TABLE).

convert

lambda to convert the raw stored value to the target Kotlin type.

Type Parameters

T

the storage class of the raw stored value (String, Int, Long, Double, or ByteArray or their nullable variants).

R

the target Kotlin type for the resulting DataFrame column. Resolved via typeOf<R>() — must be a non-abstract type reachable by reflection.


inline fun <reified T> forType(sqlTypeName: String)

Register an identity converter for every column with the given declared SQL type name: values pass through unchanged, but the DataFrame column type is fixed to T (resolved via typeOf<T>()).

Useful when SQLite's type affinity misclassifies your column and the built-in mapping resolves the wrong Kotlin type. Example: a column declared MY_ID has NUMERIC affinity (no INT/CHAR/BLOB/REAL/FLOA/DOUB substring), so SQLite will happily convert '42' to an integer on insert; declaring forType<String>("MY_ID") pins the column to String regardless.

Type Parameters

T

the target Kotlin type for the resulting DataFrame column — must be one of the storage-class types the driver actually returns (String, Int, Long, Double, or ByteArray or their nullable variants).

Example

Sqlite.withCustomConverters {
forType<String?>("LONGVARCHAR") // read as `String?` even though affinity says NUMERIC
forType<ByteArray?>("BINARY_ID") // read as raw bytes
}