[
https://issues.jboss.org/browse/JBRULES-3302?page=com.atlassian.jira.plug...
]
Troy Parrish updated JBRULES-3302:
----------------------------------
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
was:
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
Forum Reference:
http://drools.46999.n3.nabble.com/Inadvertant-type-conversion-while-using...
(was:
http://drools.46999.n3.nabble.com/Inadvertant-type-conversion-while-using...)
Unwanted type coersion of String to float values when using
"in" keyword LHS
----------------------------------------------------------------------------
Key: JBRULES-3302
URL:
https://issues.jboss.org/browse/JBRULES-3302
Project: Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: drools-compiler (expert)
Affects Versions: 5.2.0.Final, 5.3.0.Final
Environment: Windows 7, Rational Application Developer 7.5, Eclipse Helios
Service Release 2
Reporter: Troy Parrish
Assignee: Mark Proctor
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
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira