Column extensions eqOrIsNull and neqOrIsNotNull

This commit is contained in:
InsanusMokrassar 2023-01-14 20:17:57 +06:00
parent f44a78a5f5
commit 592c5f3732
2 changed files with 25 additions and 0 deletions

View File

@ -10,6 +10,8 @@
* `Ktor`: * `Ktor`:
* `Client`: * `Client`:
* All clients repos got opportunity to customize their flows * All clients repos got opportunity to customize their flows
* `Exposed`:
* Extensions `eqOrIsNull` and `neqOrIsNotNull` for `Column`
## 0.16.5 ## 0.16.5

View File

@ -0,0 +1,23 @@
package dev.inmo.micro_utils.repos.exposed
import org.jetbrains.exposed.sql.Column
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.SqlExpressionBuilder.isNotNull
import org.jetbrains.exposed.sql.SqlExpressionBuilder.isNull
import org.jetbrains.exposed.sql.SqlExpressionBuilder.neq
fun <T> Column<T?>.eqOrIsNull(
value: T?
) = if (value == null) {
isNull()
} else {
eq(value)
}
fun <T> Column<T?>.neqOrIsNotNull(
value: T?
) = if (value == null) {
isNotNull()
} else {
neq(value)
}