[jboss-jira] [JBoss JIRA] (JBRULES-3302) Unwanted type coersion of String to float values when using "in" keyword LHS

RH Bugzilla Integration (JIRA) jira-events at lists.jboss.org
Wed Feb 15 04:14:02 EST 2012


    [ https://issues.jboss.org/browse/JBRULES-3302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12666615#comment-12666615 ] 

RH Bugzilla Integration commented on JBRULES-3302:
--------------------------------------------------

Ryan Zhang <rzhang at redhat.com> changed the Status of [bug 768952|https://bugzilla.redhat.com/show_bug.cgi?id=768952] from MODIFIED to ON_QA
                
> 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: Mario Fusco
>             Fix For: 5.4.0.Beta2
>
>
> 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

        


More information about the jboss-jira mailing list