https://kotlinlang.org logo
#squarelibraries
Title
# squarelibraries
z

Zoltan Demant

10/06/2023, 1:23 PM
I have
status TEXT AS Status NOT NULL
in my SqlDelight table, where
Status
is an enum class. Can I somehow do
WHERE status = Status.Available
instead of entering "Available"?
k

kevin.cianfarini

10/06/2023, 1:28 PM
Perhaps it's better to write a query that takes status as a parameter and pass in a Status enum at Kotlin call site?
z

Zoltan Demant

10/06/2023, 2:09 PM
Hmm you're right, I'll do that for now. Would still love a way to specify it directly in SQL as nothing other than available makes sense 😁
j

jw

10/06/2023, 2:28 PM
SQL runs in the database and therefore deals in the database representation. The
AS Status
is used only for customizing the bridge between the database and user code and even that still requires an explicit converter from the database representation to the selected type. So no, there is no way to do what you ask today but furthermore there are no plans to support it.
👍🏽 1