Feel like I'm hitting a bug. Present in 3.0 and 3....
# supabase-kt
c
Feel like I'm hitting a bug. Present in 3.0 and 3.0-dev1 (didn't try anything else)
io.github.jan.supabase.exceptions.BadRequestRestException: null value in column "type" of relation "config" violates not-null constraint
Copy code
supabase.from("config").insert(Config())
is the failing code data class has a hardcoded type field
Copy code
@Serializable
data class Config(
    val type: String = "abc"
)
but if I keep everything else the same, but change the invocation to have an explicit type
Copy code
supabase.from("config").insert(Config("xyz"))
then it works. Seems like supabase-kt doesn't pick up the default value of a data class?
j
That is because by default, KotlinX Serialization (the default serializer used by supabase-kt) does not encode default values. You can change this by providing a custom
Json
instance:
Copy code
val supabase = createSupabaseClient(url, key) {
    defaultSerializer = KotlinXSerializer(Json { encodeDefaults = true })
}
Too many defaults in one sentence
c
Interesting! I'm used to moshi and I guess it does the opposite. Glad it was a quick change. phew