Could you help me please with SQLDelight? I use SQ...
# squarelibraries
в
Could you help me please with SQLDelight? I use SQLDelight for Kotlin Multiplatform Project (Android + iOS) with SQLite under the hood. SQLite has NUMERIC type for storing high precision values. I need NUMERIC type for storing currency amount, but I can't use this type in SQLDelight for some reasons. How can I store currency amount using SQLDelight?
image.png
d
SQLDelight doesn't really deal with SQLite's type affinities. It forces you to choose a storage class directly. As I understand it, the
NUMERIC
affinity doesn't necessarily offer high precision. A numerical value will be stored with either the
INTEGER
or
REAL
storage classes, or it may otherwise be stored as
TEXT
if you try storing a malformed string representation of a number.
z
Fwiw, when looking into doing the same thing I ended up storing the string representation of a BigDecimal. Might also be worth looking into scaling down the amount so that you can store it as INTEGER.
👍 1