Implements a raw add on to the query builder
This commit is contained in:
+4
@@ -21,6 +21,10 @@
|
||||
package com.vitorpamplona.quartz.nip01Core.store.sqlite.sql
|
||||
|
||||
sealed class Condition {
|
||||
data class Raw(
|
||||
val condition: String,
|
||||
) : Condition()
|
||||
|
||||
data class Equals(
|
||||
val column: String,
|
||||
val value: Any?,
|
||||
|
||||
+3
@@ -38,6 +38,9 @@ class SqlSelectionBuilder(
|
||||
*/
|
||||
private fun buildCondition(cond: Condition): String =
|
||||
when (cond) {
|
||||
is Condition.Raw -> {
|
||||
cond.condition
|
||||
}
|
||||
is Condition.Equals -> {
|
||||
if (cond.value == null) {
|
||||
"${cond.column} IS NULL"
|
||||
|
||||
+2
@@ -23,6 +23,8 @@ package com.vitorpamplona.quartz.nip01Core.store.sqlite.sql
|
||||
class WhereClauseBuilder {
|
||||
private val conditions = mutableListOf<Condition>()
|
||||
|
||||
fun raw(condition: String) = apply { conditions.add(Condition.Raw(condition)) }
|
||||
|
||||
fun equals(
|
||||
column: String,
|
||||
value: Any?,
|
||||
|
||||
Reference in New Issue
Block a user