Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repositories {
mavenCentral()
}

version = "1.1.7-SNAPSHOT"
version = "1.1.8-SNAPSHOT"
group = "org.hisp.dhis.lib.expression"

if (project.hasProperty("removeSnapshotSuffix")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ internal class Calculator(
NamedFunction.d2_hasUserRole -> functions.d2_hasUserRole(
evalToString(fn.child(0)),
data.supplementaryValues["USER"])
NamedFunction.d2_hasValue -> functions.d2_hasValue(evalToVar(fn.child(0)))
NamedFunction.d2_hasValue -> try {
functions.d2_hasValue(evalToVar(fn.child(0)))
} catch (e: IllegalExpressionException) {
false
}
NamedFunction.d2_inOrgUnitGroup -> functions.d2_inOrgUnitGroup(
evalToString(fn.child(0)),
data.programRuleVariableValues["org_unit"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@ import kotlin.test.assertEquals
*/
internal class HasValueTest : AbstractVariableBasedTest() {
@Test
fun return_false_for_non_existing_variable() {
fun return_false_for_non_existing_variable_with_UID() {
// 'nonexisting' is treated as valid UID
assertHasValue("d2:hasValue(#{nonexisting})", mapOf(), false)
}

@Test
fun return_false_for_non_existing_variable_with_name() {
assertHasValue("d2:hasValue(#{variable-name})", mapOf(), false)
}


@Test
fun return_false_for_existing_variable_without_value() {
assertHasValue(
Expand Down
Loading