[jboss-jira] [JBoss JIRA] (DROOLS-4560) executable-model wrongly calculates in eval with parenthesis
Toshiya Kobayashi (Jira)
issues at jboss.org
Tue Sep 24 03:53:00 EDT 2019
Toshiya Kobayashi created DROOLS-4560:
-----------------------------------------
Summary: executable-model wrongly calculates in eval with parenthesis
Key: DROOLS-4560
URL: https://issues.jboss.org/browse/DROOLS-4560
Project: Drools
Issue Type: Bug
Components: executable model
Affects Versions: 7.27.0.Final
Environment: - executable-model
Reporter: Toshiya Kobayashi
Assignee: Luca Molteni
executable-model wrongly calculates in eval with parenthesis.
For example, with this rule,
{noformat}
import org.drools.modelcompiler.domain.CalcFact;rule R when
$p : CalcFact( $v1 : value1, $v2 : value2 )
eval( ($v1 / ($v2 * 10) * 10) > 25 )
then
end
{noformat}
if $v1 = 1 and $v2 = 1, ($v1 / ($v2 * 10) * 10) is 1. So the rule should not fire.
However, executable-model generates Java code:
{code:java}
public class Rules4A265EF484FEEE0E4E84E77B3DEB48F9RuleMethods0 {
/**
* Rule name: R
*/
public static org.drools.model.Rule rule_R() {
final org.drools.model.Variable<org.drools.modelcompiler.domain.CalcFact> var_$p = D.declarationOf(org.drools.modelcompiler.domain.CalcFact.class,
"$p");
final org.drools.model.Variable<Double> var_$v1 = D.declarationOf(Double.class,
"$v1");
final org.drools.model.Variable<Double> var_$v2 = D.declarationOf(Double.class,
"$v2");
org.drools.model.Rule rule = D.rule("R").build(D.bind(var_$v1).as(var_$p,
(_this) -> _this.getValue1()).reactOn("value1"),
D.bind(var_$v2).as(var_$p,
(_this) -> _this.getValue2()).reactOn("value2"),
D.expr("454A1C822808AC7491268E4F381F0EDA",
var_$v1,
var_$v2,
($v1, $v2) -> org.drools.modelcompiler.util.EvaluationUtil.greaterThanNumbers($v1 / $v2 * 10 * 10,
25d)),
D.execute(() -> {
}));
return rule;
}
}
{code}
See that parentheses are removed so ($v1 / ($v2 * 10) * 10) becomes 100.
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
More information about the jboss-jira
mailing list