On 31 December 2010 19:05, Michael Whidden <span dir="ltr">&lt;<a href="mailto:mwhidden@thebluew.com">mwhidden@thebluew.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thank you! That fixes it, without using getter methods. So did I make a<br>
mistake, or is this a workaround for a bug?<br></blockquote><div><br>Very careful reading of the very, very small print in the Expert manual section describing the various forms of field constraints will tell you that one of the forms of single value restrictions is the &quot;Return Value Restriction&quot;, a parhenthesized expressiion, which is the form where any Java expression is permitted. (The alternatives use either a literal, a variable or a qualified identifier. Your construct would qualify syntactically for the latter - I&#39;m not sure where the current Drools version draws the line; future releases might relax this limitation.) <br>
<br>Seemingly unnecessary parentheses are the distinction for the Drools parser to throw the contents into the generated Java code &quot;as is&quot;.<br><br>-W<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<br>
These work:<br>
$o:Order(q &gt; (b.maxQ))<br>
$o:Order($o.q &gt; ($o.b.maxQ))<br>
$o:Order(b.maxQ &gt; q)<br>
$o:Order($o.b.maxQ &gt; $o.q)<br>
<br>
These don&#39;t:<br>
$o:Order(q &gt; b.maxQ)<br>
$o:Order($o.q &gt; $o.b.maxQ)<br>
<br>
Is this proper behavior, or a bug? I can&#39;t find anything in the docs<br>
that describes the parens as required when a qualified identifier<br>
appears on the right side of a binary operator in a constraint.<br>
<br>
<br>
On 12/31/2010 11:47 AM, Wolfgang Laun wrote:<br>
&gt; Try parenthesizing the right hand side but note that you may have to use<br>
&gt; getters to access the fields<br>
&gt;     $o:Order($o.q &gt; ($o.getB().getMaxQ() ) )<br>
&gt;<br>
&gt; It&#39;s possible that using dialect &quot;mvel&quot; might be a way to avoid using<br>
&gt; the getX() instead of x.<br>
&gt;<br>
&gt; -W<br>
&gt;<br>
&gt;<br>
&gt; On 31 December 2010 17:30, Michael Whidden &lt;<a href="mailto:mwhidden@thebluew.com">mwhidden@thebluew.com</a><br>
&gt; &lt;mailto:<a href="mailto:mwhidden@thebluew.com">mwhidden@thebluew.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     At Mr. Legendre&#39;s suggestion, I removed the $o from my constraints, but<br>
&gt;     with the same result: (b.maxQ &lt; q) works, but (q &gt; b.maxQ) fails. I get<br>
&gt;     the error:<br>
&gt;     &quot;Unable to create restriction &#39;[QualifiedIndentifierRestr: &lt; b.maxQ ]&#39;<br>
&gt;     for field &#39;quantity&#39; in the rule &#39;MaxQty&#39;&quot;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;     On 12/30/2010 2:32 PM, Michael Whidden wrote:<br>
&gt;      &gt; I notice an unexpected behavior when creating a technical DRL in<br>
&gt;     Guvnor.<br>
&gt;      &gt;<br>
&gt;      &gt; If I have a fact with a sub-fact, then binary operators don&#39;t<br>
&gt;     seem to be<br>
&gt;      &gt; commutative.<br>
&gt;      &gt;<br>
&gt;      &gt; Eg.,<br>
&gt;      &gt;<br>
&gt;      &gt; declare Broker<br>
&gt;      &gt; maxQ: Integer<br>
&gt;      &gt;<br>
&gt;      &gt; declare Order<br>
&gt;      &gt; q: Integer<br>
&gt;      &gt; b: Broker<br>
&gt;      &gt;<br>
&gt;      &gt; The rule<br>
&gt;      &gt; $o:Order($o.b.maxQ &lt; $o.q)<br>
&gt;      &gt; validates fine, but<br>
&gt;      &gt; $o:Order($o.q &gt; $o.b.maxQ)<br>
&gt;      &gt; returns an error &quot;Unable to create restriction<br>
&gt;      &gt; &#39;[QualifiedIndentifierRestr: &gt; $o.broker.maxQ ]&#39; for field &#39;$o.q&#39;<br>
&gt;     in the<br>
&gt;      &gt; rule&quot;<br>
&gt;      &gt;<br>
&gt;      &gt; I&#39;m new, so I want to make sure I&#39;m not missing something obvious<br>
&gt;     here...<br>
&gt;<br>
&gt;     _______________________________________________<br>
&gt;     rules-users mailing list<br>
&gt;     <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a> &lt;mailto:<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>&gt;<br>
&gt;     <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<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>
</blockquote></div><br>