Typing casting from JSON_OBJECT()
Im using mysql / planetscale. When I select a field that is a boolean (tinyint in database) drizzle returns a boolean. However when selecting that field inside of a JSON_OBJECT, it will return as a tinyint. Is there any method I'm missing to cast this as a boolean inside the query, or will I just have to do this after the query execution?
4 Replies
Can you show the query that you're trying to run?
Psuedo code sorry. For this bool field it will return for bool_field "1" or "0"
compared to
which returns a true / false
It's not a major issue I guess.. can just cast later in my code - just wondering if there's a method for casting inside the query that I missed.
You can use the mapWith method in the sql operator
You pass a function that will get called for each row in that field
FWIW - I wouldn't expect/want that to behave differently. Since it's JSON, there's no way to know if
{xyz: 0}
should mean xyz = false or if it should be 0.