https://kotlinlang.org logo
#exposed
Title
# exposed
k

Khurram Malik

12/31/2021, 8:45 PM
I cannot update the expose dependencies reason being the IntIdTable primaryKey field is now final (in newer versions of the dependencies, from version 0.36.1 to be precise):
/**
 * Identity table with autoincrement integer primary key
 *
 * @param name table name, by default name will be resolved from a class name with "Table" suffix removed (if present)
 * @param columnName name for a primary key, "id" by default
 */
open class IntIdTable(name: String = "", columnName: String = "id") : IdTable<Int>(name) {
    final override val id: Column<EntityID<Int>> = integer(columnName).autoIncrement().entityId()
    final override val primaryKey by lazy { super.primaryKey ?: PrimaryKey(id) }
}
This field was earlier not final and we were able to override it for several tables by combining/linking two tables:
object AnswersInQuestionTable : IntIdTable("answers_in_question"){
    val question = reference("question_id", QuestionsTable)
    val answer = reference("answer_id", AnswersTable)
    override val primaryKey = PrimaryKey(question, answer)
}
This is a an issue for our web service. Anyone who know what the best practice(s) are for resolving that?
d

dave08

01/02/2022, 4:13 AM
Make your own IntIdTable?
k

Khurram Malik

01/02/2022, 5:56 PM
Yes, that is as an relativ easy solution. However, we are not sure if what we are doing is recommended. So it would be much more convenient to change the implementation according to the recommendations.