From 4363697fa0ef63f4c2cfd2b2e5545d142c6917a1 Mon Sep 17 00:00:00 2001 From: Tanmay Ranjan Date: Wed, 4 Dec 2024 16:47:38 +0530 Subject: [PATCH 1/2] Fix : In array condition is failing when attribute value is null --- src/main/kotlin/com/featurevisor/sdk/Conditions.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/featurevisor/sdk/Conditions.kt b/src/main/kotlin/com/featurevisor/sdk/Conditions.kt index bef5b03..922d3ab 100644 --- a/src/main/kotlin/com/featurevisor/sdk/Conditions.kt +++ b/src/main/kotlin/com/featurevisor/sdk/Conditions.kt @@ -111,10 +111,11 @@ object Conditions { } } - attributeValue is AttributeValue.StringValue && conditionValue is ConditionValue.ArrayValue -> { + conditionValue is ConditionValue.ArrayValue -> { + val valueInContext = (context[attributeKey] as? AttributeValue.StringValue)?.value when (operator) { - IN_ARRAY -> attributeValue.value in conditionValue.values - NOT_IN_ARRAY -> (attributeValue.value !in conditionValue.values) + IN_ARRAY -> valueInContext in conditionValue.values + NOT_IN_ARRAY -> valueInContext !in conditionValue.values else -> false } } From bdcd343ef69c2ab951f272daf60001fc56dcc1ed Mon Sep 17 00:00:00 2001 From: Tanmay Ranjan Date: Wed, 4 Dec 2024 17:00:30 +0530 Subject: [PATCH 2/2] keep attributeValue as Int in top --- src/main/kotlin/com/featurevisor/sdk/Conditions.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/com/featurevisor/sdk/Conditions.kt b/src/main/kotlin/com/featurevisor/sdk/Conditions.kt index 922d3ab..d5d39e9 100644 --- a/src/main/kotlin/com/featurevisor/sdk/Conditions.kt +++ b/src/main/kotlin/com/featurevisor/sdk/Conditions.kt @@ -111,19 +111,19 @@ object Conditions { } } - conditionValue is ConditionValue.ArrayValue -> { - val valueInContext = (context[attributeKey] as? AttributeValue.StringValue)?.value + attributeValue is AttributeValue.IntValue && conditionValue is ConditionValue.ArrayValue -> { when (operator) { - IN_ARRAY -> valueInContext in conditionValue.values - NOT_IN_ARRAY -> valueInContext !in conditionValue.values + IN_ARRAY -> attributeValue.value.toString() in conditionValue.values + NOT_IN_ARRAY -> (attributeValue.value.toString() !in conditionValue.values) else -> false } } - attributeValue is AttributeValue.IntValue && conditionValue is ConditionValue.ArrayValue -> { + conditionValue is ConditionValue.ArrayValue -> { + val valueInContext = (context[attributeKey] as? AttributeValue.StringValue)?.value when (operator) { - IN_ARRAY -> attributeValue.value.toString() in conditionValue.values - NOT_IN_ARRAY -> (attributeValue.value.toString() !in conditionValue.values) + IN_ARRAY -> valueInContext in conditionValue.values + NOT_IN_ARRAY -> valueInContext !in conditionValue.values else -> false } }