-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix evaluation of is not defined expression #108
Conversation
|
||
@Override | ||
public Function1<PrototypeFactInstance, Object> asFunction(Prototype prototype) { | ||
return delegate.asFunction(prototype).andThen( result -> result == Prototype.UNDEFINED_VALUE ? ADMITTED_UNDEFINED_VALUE : result ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main fix and it is necessary to workaround the fact that on the Drools side it prevents any constraint evaluation, returning false, when it meets an UNDEFINED_VALUE
. I preferred to avoid modifying Drools and fix the problem only here. However I believe that, with this trick, it is not bad that an undefined value is actually evaluated only for this constraint (which is the only one that we know at the moment where this is necessary) and not for each and every constraint that at that point will have to deal with it for no reason.
return ExistsField.INSTANCE; | ||
case ExistsField.NEGATED_EXPRESSION_NAME: | ||
// IsNotDefinedExpression behaves as an existential not only when used alone | ||
return ruleContext.getCondition().isSingleCondition() ? ExistsField.INSTANCE : NegatedExistsField.INSTANCE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I'm clearly making a distinction between the case when the IsNotDefinedExpression
is used alone, when it is evaluated as our not
existential operator, or in conjuction with another constraint, when it is simply the negation of IsDefinedExpression
.
* Adding isNotDefined test (#105) * Clarify IsNotDefined operator behaviour when used alone (#106) * Fix evaluation of is not defined expression (#108) --------- Co-authored-by: Mario Fusco <[email protected]>
No description provided.