The use of multi-restriction or the use of "in" operator causes a unwanted coersion from String types to decimal types. For example (Message.message is String and someEntity.someString is String as well): Message message = new Message(); SomeEntity someEntity = new SomeEntity(); someEntity.setSomeString("1.5"); message.setSomeEntity(someEntity); message.setMessage("1.5"); ksession.insert(message); ksession.fireAllRules(); rule "R1" dialect "java" salience 2 when Message($message: message in ("1.500") ) then System.out.println("Result for R1 " + $message ); end rule "R2" dialect "java" salience 1 when m: Message( someEntity.someString in ("1.500") ) then System.out.println("Result for R2 " + m.getSomeEntity().getSomeString() ); end Using Drools 5.2 and Drools 5.3 you have printed: "Result for R1 1.5 Result for R2 1.5" ... there, was done a coercion to decimal and all conditionals returned true then the rules were fired. If used a single constraint with "==" operator instead of "in", no rule is fired (as expected). Using Drools 5.0.x and Drools 5.1.x the result is different, only R2 is fired... so there is the same problem, but only for nested objects. The fix should works for both cases, nested objects and for direct access for properties. I am not sure if Multi-restriction is a MVEl feature, I think it is implemented by pure Drools parser, so I am not opening a new MVEL issue based on that. However, let me know if it is necessary.
Created attachment 548593 [details] project test Execute CoersionTest.java and look coercion.drl
Mario Fusco <mario.fusco> updated the status of jira JBRULES-3302 to Resolved
Mario Fusco <mario.fusco> made a comment on jira JBRULES-3302 That was caused by a wrong type coersion in mvel
Please verify the issue on 5.3 ER4.
Verified in BRMS 5.3 ER4.
Technical note added. If any revisions are required, please edit the "Technical Notes" field accordingly. All revisions will be proofread by the Engineering Content Services team. New Contents: When the 'in' keyword is used to evaluate a String value against a set of values in the LHS of the rule, the String is treated as a float value. This was caused by a wrong type coercion in MVEL. The issue has been resolved and String values are now treated as Strings when used with the 'in' keyword.
This product has been discontinued or is no longer tracked in Red Hat Bugzilla.