Faster way of coding equals to null in the sql builder
This commit is contained in:
+12
-4
@@ -39,12 +39,20 @@ class SqlSelectionBuilder(
|
|||||||
private fun buildCondition(cond: Condition): String =
|
private fun buildCondition(cond: Condition): String =
|
||||||
when (cond) {
|
when (cond) {
|
||||||
is Condition.Equals -> {
|
is Condition.Equals -> {
|
||||||
selectionArgs.add(cond.value.toString())
|
if (cond.value == null) {
|
||||||
"${cond.column} = ?"
|
"${cond.column} IS NULL"
|
||||||
|
} else {
|
||||||
|
selectionArgs.add(cond.value.toString())
|
||||||
|
"${cond.column} = ?"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
is Condition.NotEquals -> {
|
is Condition.NotEquals -> {
|
||||||
selectionArgs.add(cond.value.toString())
|
if (cond.value == null) {
|
||||||
"${cond.column} != ?"
|
"${cond.column} IS NULL"
|
||||||
|
} else {
|
||||||
|
selectionArgs.add(cond.value.toString())
|
||||||
|
"${cond.column} != ?"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
is Condition.GreaterThan -> {
|
is Condition.GreaterThan -> {
|
||||||
selectionArgs.add(cond.value.toString())
|
selectionArgs.add(cond.value.toString())
|
||||||
|
|||||||
Reference in New Issue
Block a user