<br> Hi Jevon,<br><br> That is a discussion we had for some time (whether "from" should check return type or not for matching purposes). The only reason it was not implemented so far is that it would possibly cause "silent failures". Example:<br>
<br>Person( name == "bob" ) from $people<br><br> If $people returns an Alien() and the check is in place, the rule will not match and the user might not notice the reason, as the way it is today, it will raise a ClassCastException.<br>
<br> Although, in my opinion, the advantages of the check surpass the "silent failure" problem and we should add this check, specially because sometimes you have a collection of objects that share a common superclass, but with different actual subclasses instances, and you want to operate only on a give subclass.<br>
<br> Anyway, I will talk with Mark and possibly add this to Drools 5.1.<br><br> Regarding your keyword usage issue, I added a comment to it:<br><br><a href="https://jira.jboss.org/jira/browse/JBRULES-2218">https://jira.jboss.org/jira/browse/JBRULES-2218</a><br>
<br> Regards,<br> Edson<br><br><div class="gmail_quote">2010/2/24 Jevon Wright <span dir="ltr"><<a href="mailto:jevon@jevon.org">jevon@jevon.org</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>I am using Drools 4.0.7, and I had a DRL rule similar to the following:<br><br>rule "..."<br> when<br> other : Foo( )<br> x : Bar( ) from other.property<br><br> then<br> ...<br>end<br><br>An unexpected bug occured. In some situations, other.property would _not_ be of type Bar, yet Drools would still think that it was. As a result I was getting some unusual exceptions being thrown: "org.mvel.CompileException: unable to resolve property: ..."<br>
<br>If I changed the rule to:<br> x : Bar( ) from other.property<br> eval ( x instanceof Bar )<br><br>It would instead throw a ClassCastException (i.e. "Baz cannot be cast into Bar").<br><br>If, instead, I changed the rule to:<br>
x : Bar( other.property == x ) <br><br>It would start working correctly, and 'x' would only be of type Bar.<br><br>Is this known behaviour? Is it expected? If so, I would appreciate it if the 4.0.7 documentation was updated to reflect that "from" actually ignores the return type of properties. It took me a couple of hours to detect and fix this bug.<br>
<br>I would try these rules in Drools 5.x, but I'm still waiting for the blocking JBRULES-2218 to be resolved.<br><br>Cheers<br><font color="#888888">Jevon<br>
</font><br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>