Skip to content

Commit

Permalink
fix: allow null in filter comparisons
Browse files Browse the repository at this point in the history
This allows us to use `null` in filters where `null` is compared to
the item, or when the item is `null` explicitly.

It does not yet help us deal with variables that are missing, as this
produces an error.

Co-authored-by: berkaycanbc <berkay.can@camunda.com>
Co-authored-by: Nicola Puppa <nicola.puppa@camunda.com>
Co-authored-by: Remco Westerhoud <remco@westerhoud.nl>

Conflicts:
 src/main/scala/org/camunda/feel/impl/interpreter/FeelInterpreter.scala

Resolution:
 we ignore the change on the other case (previously a ValError, now
 error). Instead, we use the change we proposed (ignore this entry and
 continue with the others).
  • Loading branch information
korthout committed Jul 21, 2023
1 parent 046f67a commit 04c123a
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -789,9 +789,9 @@ class FeelInterpreter {
val withBooleanFilter = (list: List[Val]) => mapEither[Val, Val](
list,
item =>
withBoolean(filter(item), {
case true => item
case false => conditionNotFulfilled
(filter(item) match {
case ValBoolean(true) => item
case _ => conditionNotFulfilled
}).toEither,
items => ValList(items.filterNot(_ == conditionNotFulfilled))
)
Expand All @@ -809,7 +809,10 @@ class FeelInterpreter {
case fulFilledItems: ValList => fulFilledItems
case error => error
}
case other => error(s"Expected boolean filter or number but found '$other'")
case _ => withBooleanFilter(list.tail) match {
case ValList(fulFilledItems) => ValList(fulFilledItems)
case error => error
}
})
).getOrElse(
// Return always an empty list if the given list is empty. Note that we would return `null`
Expand Down

0 comments on commit 04c123a

Please sign in to comment.