ktorm icon indicating copy to clipboard operation
ktorm copied to clipboard

Transform nullable columns

Open catsuperberg opened this issue 1 year ago • 4 comments

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 }

catsuperberg avatar Mar 22 '23 18:03 catsuperberg