ktorm
ktorm copied to clipboard
Transform nullable columns
If nullable properties are allowed in Entity and databases overall support null fields, why wouldn't transform method be able to accept null from fromUnderlyingValue. IDK maybe i'm doing something wrong but i have serializable FloatRange class and as a field for it isn't essential i would prefer to get null on failed serialization. As it is now i can't find any other option but use some default value or split range into two columns for min and max.
I use it like so:
val range = varchar("range").transform(
{ FloatRange.parseFromString(it) ?: FloatRange(0f, 0f) }, { it.toString() }
).bindTo { it.range }