Details
-
Bug
-
Resolution: Done
-
Major
-
5.2.0.Final, 5.3.0.Final
-
None
Description
String values get treated as float values even when fact declares the property as a String when using the "in" keyword to evaluate a String value against a set of values in the lhs of the rule.
Example:
input into session : "10.5"
will match against all of the following values "10.5", "10.50", "10.500" etc when in this format:
when
Fact(string in ("11.5", "10.50", "11.500"))
then
This problem behavior occurs in 5.3.0Final, 5.2.0.Final but not in 5.1.0Final, this is when Expert went from using mvel 2.0.16 to mvel 2.1.0
Further information based on recent findings (12/02/2011)
When inserting a Fact with a Property that is an Object and the LHS references a property of that object there is the unwanted type coercion even in 5.1.0Final
IE:
Class BigTest has two properties: Test and id. Test is an Object with a single property: code.
If we reference in the LHS BigTest(test.code in (.....)) we get the unwanted coercion, but when we reference BigTest(id in (.....)) the coercion does not occur. This is for 5.1.0Final. We find that the coercion takes place for both the syntax of BigTest(id in (......)) and BigTest(test.code in (.....)) when using 5.2.0Final and up. Example code below:
CLASSES:
public class BigTest {
private Test test;
private String id;
getters and setters .....
public class Test {
private String code;
getters and setters .....
DRL:
rule "Test.Code One"
when
BigTest($code : test.code in ("1.50", "2.50"))
then
System.out.println("Code compared values: 1.50, 2.50 - actual code value: " + $code);
end
rule "Test.Code Two"
when
BigTest($code : test.code in ("1.5", "2.5"))
then
System.out.println("Code compared values: 1.5, 2.5 - actual code value: " + $code);
end
rule "Big Test ID One"
when
BigTest($id : id in ("3.5", "4.5"))
then
System.out.println("ID compared values: 3.5, 4.5 - actual ID value: " + $id);
end
rule "Big Test ID Two"
when
BigTest($id : id in ( "3.0", "4.0"))
then
System.out.println("ID compared values: 3.0, 4.0 - actual ID value: " + $id);
end