mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-18 14:47:15 +00:00
Column extensions eqOrIsNull and neqOrIsNotNull
This commit is contained in:
parent
f44a78a5f5
commit
592c5f3732
@ -10,6 +10,8 @@
|
||||
* `Ktor`:
|
||||
* `Client`:
|
||||
* All clients repos got opportunity to customize their flows
|
||||
* `Exposed`:
|
||||
* Extensions `eqOrIsNull` and `neqOrIsNotNull` for `Column`
|
||||
|
||||
## 0.16.5
|
||||
|
||||
|
@ -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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user