uShortColumn

protected fun uShortColumn(name: String): KQLiteColumn<UShort?>

Defines a nullable SMALLINT UNSIGNED column in the table, intended to store an unsigned 16-bit integer (UShort).

This function creates and registers a column with the type SMALLINT UNSIGNED. While SQLite does not have a native unsigned integer type, this function maps the database value to Kotlin's UShort for type safety and to represent values up to UShort.MAX_VALUE. The column is nullable by default.

Important: UShort values are stored as Int to prevent overflow. So, this is safe to use without overflow issues.

Example:

object DeviceSettings : KQLiteTable("device_settings") {
// A nullable SMALLINT UNSIGNED column for a port number, which is always positive
val portNumber = uShortColumn("port_number")

// A non-null column for a configuration flag
val configFlag = uShortColumn("config_flag").notNull().default(0u)
}

Return

A KQLiteColumn instance representing the SMALLINT UNSIGNED column, which can be further chained with constraints like notNull(), default(), etc.

Author

MOHAMMAD AZIM ANSARI

Parameters

name

The name of the column in the database.

See also