Fixed conditions in sql queries

This commit is contained in:
Viktor De Pasquale 2019-05-12 18:34:28 +02:00
parent 0245e13591
commit 125ae0a173
3 changed files with 9 additions and 6 deletions

View File

@ -8,7 +8,7 @@ object Constants {
val MAGISK_PATH = "/sbin/.magisk/img"
val MAGISK_LOG = "/cache/magisk.log"
val USER_ID = Process.myUid() / 100000
val USER_ID get() = Process.myUid() / 100000
const val SNET_REVISION = "b66b1a914978e5f4c4bbfd74a59f4ad371bac107"
const val BOOTCTL_REVISION = "9c5dfc1b8245c0b5b524901ef0ff0f8335757b77"

View File

@ -36,13 +36,13 @@ class PolicyDao(
fun delete(uid: Int) = query<Delete> {
condition {
equals("uid", uid.toString())
equals("uid", uid)
}
}.ignoreElement()
fun fetch(uid: Int) = query<Select> {
condition {
equals("uid", uid.toString())
equals("uid", uid)
}
}.map { it.first().toPolicy(context.packageManager) }
.doOnError {
@ -57,7 +57,7 @@ class PolicyDao(
fun fetchAll() = query<Select> {
condition {
equals("uid/100000", Constants.USER_ID.toString())
equals("uid/100000", Constants.USER_ID)
}
}.flattenAsFlowable { it }
.map { it.toPolicy(context.packageManager) }

View File

@ -107,8 +107,11 @@ class Condition {
private val conditionWord = "WHERE %s"
private var condition: String = ""
fun equals(field: String, value: String) {
condition = "$field=\"$value\""
fun equals(field: String, value: Any) {
condition = when (value) {
is String -> "$field=\"$value\""
else -> "$field=$value"
}
}
fun greaterThan(field: String, value: String) {