[jboss-jira] [JBoss JIRA] Created: (JBRULES-954) '==' & '!=' not working properly with globals
Brian Enderle (JIRA)
jira-events at lists.jboss.org
Wed Jun 27 15:48:57 EDT 2007
'==' & '!=' not working properly with globals
---------------------------------------------
Key: JBRULES-954
URL: http://jira.jboss.com/jira/browse/JBRULES-954
Project: JBoss Rules
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: Drl Parser/Builder
Affects Versions: 4.0.0.MR3
Environment: Windows XP, Drools MR3
Reporter: Brian Enderle
Assigned To: Mark Proctor
The equality operators (== & !=) are not working correctly when comparing a value to a global. This holds true for globals of the type java.lang.Character and java.lang.String.
Given:
Person object with sex set to 'M'
rule "Must be male"
when
$p : Person ( sex == 'M' )
then
System.out.println ( "- This is a man" );
end
rule "Cannot be a man"
when
$p : Person ( sex != 'M')
then
System.out.println ( "- This must be a woman")
end
Results:
- This is a man
If we replace the 'M' with the global "maleCode" and set it to 'M' in our calling program then,
gloabl java.lang.Character maleCode;
rule "Must be male"
when
$p : Person ( sex == maleCode )
then
System.out.println ( "- This is a man" );
end
rule "Cannot be a man"
when
$p : Person ( sex != maleCode)
then
System.out.println ( "- This must be a woman")
end
Results:
- This is a man
- This must be a woman
Both rules are passing when one, the latter, should fail
Brian Enderle
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list