How to add multi-parameter annotation class to sql data table #5553
-
I have a custom annotation class look like this @Target(AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION)
annotation class TableHeader(
val headerText: String,
val columnIndex: Int,
val isTime: Boolean = false
) I want to add annotation to my data table like this CREATE TABLE roundData (
time INTEGER AS @TableHeader("gui.tab.table_header.log_data.time", 0, true) Long PRIMARY KEY NOT NULL,
roundType INTEGER AS @TableHeader("gui.tab.table_header.round_data.round_type", 1) RoundType NOT NULL,
map TEXT NOT NULL,
mapId INTEGER AS Int NOT NULL,
roundTime INTEGER NOT NULL,
playerTime INTEGER NOT NULL,
players TEXT AS MutableList<PlayerData> NOT NULL,
terrors TEXT AS ArrayList<Int> NOT NULL,
isDeath INTEGER AS Boolean NOT NULL,
isWon INTEGER AS WonOrLost NOT NULL
); The problem is, sqldelight don't let me to do this, so what should i do to add multi-parameter annotation to the sql data table? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Currently there is no support for annotating the data class table interface Similar features have been previously discussed #3104 (comment) with some kind of module support to customise the code gen process. The only way is to create a separate model class - with your annotations - using the type-safe mapper api https://sqldelight.github.io/sqldelight/2.0.2/android_sqlite/custom_projections/#type-projections |
Beta Was this translation helpful? Give feedback.
Currently there is no support for annotating the data class table interface
Similar features have been previously discussed #3104 (comment) with some kind of module support to customise the code gen process.
The only way is to create a separate model class - with your annotations - using the type-safe mapper api https://sqldelight.github.io/sqldelight/2.0.2/android_sqlite/custom_projections/#type-projections