How do I handle null values in `flatZip` compositi...
# komapper
d
How do I handle null values in
flatZip
composition queries? Maybe there should be a
flatZipNotNull
?
t
When might you need
flatZipNotNull
? Could you show me an example of the code?
d
Copy code
val q = QueryDsl.from(f)
          .where { ... }
          .firstOrNull()
          .flatZipNotNull {
              // If result of firstOrNull is null the result of q is null, otherwise run second request with a non-null value
           }
Otherwise, there's nothing to do with the
it
in flatZip other than using !! and catching the exception to return
null
as the result... 🙈
t
Thank you. That’s an interesting use case. I’ll think about how to address it.
👍🏼 1