Commit 125ae0a1 authored by Viktor De Pasquale's avatar Viktor De Pasquale

Fixed conditions in sql queries

parent 0245e135
......@@ -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"
......
......@@ -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) }
......
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment