Skip to content

Commit

Permalink
fix: json column being saved as a stringified Kotlin object (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
bard-kristian authored Sep 10, 2024
1 parent c389894 commit b77d023
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class JsonColumnType<T : Any>(
@Suppress("UNCHECKED_CAST")
override fun valueFromDB(value: Any): T {
return when (value) {
is ByteArray -> parse(String(value).unescapeSqlJsonString())
is ByteArray -> parse(value.decodeToString().unescapeSqlJsonString())
else -> value as T
}
}
Expand All @@ -69,6 +69,13 @@ class JsonColumnType<T : Any>(
value
}
}

override fun notNullValueToDB(value: T): Any = stringify(value)

override fun valueToString(value: T?): String = when (value) {
is Iterable<*> -> nonNullValueToString(value)
else -> super.valueToString(value)
}
}

/**
Expand Down

0 comments on commit b77d023

Please sign in to comment.