I use Exposed library in Kotlin project. On my table declaration, I have a column like this:
val updatedDate = datetime("updated_dt").clientDefault { DateTime.now() }
What different if I replace clientDefault function by default as below:
val updatedDate = datetime("updated_dt").default(DateTime.now())
I've see source code of this two function, but still no idea.
clientDefault function:
fun <T:Any> Column<T>.clientDefault(defaultValue: () -> T): Column<T> {
this.defaultValueFun = defaultValue
this.dbDefaultValue = null
return this
}
default function:
fun <T:Any> Column<T>.default(defaultValue: T): Column<T> {
this.dbDefaultValue = SqlExpressionBuilder.run {
asLiteral(defaultValue)
}
this.defaultValueFun = { defaultValue }
return this
}