https://kotlinlang.org logo
Title
d

Daniel

04/05/2023, 2:22 PM
Does exposed allow something of a "client-side type interceptor" (a function that would be called when data is retrieved from DB or inserted into and that would change its data type)? I have legacy DB with structure I cannot alter and there are lots of columns defined as decimal(x, 0) where x is in the majority of cases <= 9 (so it could fit into Int without problem). I would like to transparently convert it upon fetching/writing.
a

Alexey Soshin

04/05/2023, 9:16 PM
There are a few options.
You also could play with `customEnumeration`: https://github.com/JetBrains/Exposed/blob/master/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Table.kt#L636 This literally has
fromDB
and
toDB
transformation functions
Are you using the SQL DSL or the DAO DSL?
a

Arjan van Wieringen

04/08/2023, 7:24 PM
Isn’t this just done using a repository pattern in front of the actual data access?