Skip to content

Commit 64ef450

Browse files
committed
feat: [ANDROSDK-2309] fix search online operators
1 parent 1911431 commit 64ef450

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

core/src/main/java/org/hisp/dhis/android/core/arch/repositories/scope/internal/FilterItemOperator.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ enum class FilterItemOperator(val sqlOperator: String, val apiOperator: String,
4040
SW("LIKE", "sw", "SW"),
4141
EW("LIKE", "ew", "EW"),
4242
VOID("", "", ""),
43-
NULL_OR_BLANK("", "null_or_blank", "NULL_OR_BLANK"),
44-
NOT_NULL_AND_NOT_BLANK("", "not_null_and_not_blank", "NOT_NULL_AND_NOT_BLANK"),
43+
NULL_OR_BLANK("", "null", "NULL"),
44+
NOT_NULL_AND_NOT_BLANK("", "!null", "!NULL"),
4545
;
4646

4747
/**

core/src/main/java/org/hisp/dhis/android/core/trackedentity/search/TrackedEntityInstanceQueryOnlineHelper.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,25 +150,26 @@ internal class TrackedEntityInstanceQueryOnlineHelper(
150150
val clause = items.map { item ->
151151
val operator = if (upper) item.operator().apiUpperOperator else item.operator().apiOperator
152152

153-
":" + operator + ":" + getAPIValue(item)
153+
":" + operator + (getAPIValue(item)?.let { ":$it" } ?: "")
154154
}
155155

156156
key + clause.joinToString(separator = "")
157157
}
158158
}
159159

160-
private fun getAPIValue(item: RepositoryScopeFilterItem): String {
160+
private fun getAPIValue(item: RepositoryScopeFilterItem): String? {
161+
val value = item.value() ?: return null
161162
return when (item.operator) {
162163
FilterItemOperator.IN -> {
163-
val list = FilterOperatorsHelper.strToList(item.value()!!).map { escapeChars(it) }
164+
val list = FilterOperatorsHelper.strToList(value).map { escapeChars(it) }
164165
list.joinToString(";")
165166
}
166167

167168
FilterItemOperator.NOT_NULL_AND_NOT_BLANK,
168169
FilterItemOperator.NULL_OR_BLANK,
169-
-> ""
170+
-> null
170171

171-
else -> escapeChars(item.value()!!)
172+
else -> escapeChars(value)
172173
}
173174
}
174175

0 commit comments

Comments
 (0)