https://kotlinlang.org logo
g

Goetz Markgraf

06/20/2023, 2:06 PM
maybe I am blind, but I cannot create this where condition:
Copy code
WHERE id = <some value> AND (type = 0 OR type is null)
I tried:
Copy code
.select { id eq <some value> }
.andWhere { (type eq 0) or (type.isNull() }
However, the last statement gives an error:
Copy code
Type mismatch.
Required: Op<Boolean>
Found:    Unit
Can anyone help please? Thank you very much
d

Dominik Sandjaja

06/20/2023, 2:32 PM
Can you try
Copy code
.select { id eq <someValue> }
.andWhere { Op.Build { (type eq 0) or (type.isNull()) } }
?
g

Goetz Markgraf

06/21/2023, 6:05 AM
Thank you, that worked. Interestingly, when I remove the
Op.build
again, the error was gone. Maybe, IntelliJ imported a wrong
or
function. Now the following code is fine:
Copy code
.select { id eq <somevalue> }
.andWhere { (type eq 0) or (type.isNull()) }
👍 2
6 Views