Drools Decision Table object comparison gives inverted results
<p>I have been struggling with a problem considering Drools and this is kind of my last resort.</p>

<p>Assume I have a list of 3 people: [1, 2, 3]. Think of this list as a list of ID values for these people.
Now, I want to evaluate all unique pairs of these people in the following order:</p>

<ol>
<li>Person 1 against Person 2;</li>
<li>Person 1 against Person 3;</li>
<li>Person 2 against Person 3.</li>
</ol>

<p>My spreadsheet's RuleTable looks like this: </p>

<p><a href="https://i.stack.imgur.com/2zjCl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2zjCl.png" alt="RuleTable PSBR"></a></p>

<p>It makes use of a trick mentioned in this comment: <a href="https://stackoverflow.com/a/28276208/5347955">Drools compare two objects in decision table</a>.</p>

<p>The Person class had been correctly imported, the three people have been inserted into the session and every Person object has a <code>getId()</code> method.</p>

<p>However, running <code>fireAllRules()</code> on the session gives me the following output:</p>

<ol>
<li>Person 1 vs Person 1</li>
<li>Person 2 vs Person 1</li>
<li>Person 2 vs Person 2</li>
<li>Person 3 vs Person 1</li>
<li>Person 3 vs Person 2</li>
<li>Person 3 vs Person 3</li>
</ol>

<p>You might notice that that's the complement of the set of results I would have liked.</p>

<p><strong>Please note!</strong> After a wild guess, it turned out that changing the condition <code>id &gt; $id1</code> to<code>id &lt; $id1</code> solves this problem, but then the logic appears to not match in my head.</p>

<p>The rule I'm trying to mimic looks something as follows:</p>

<pre><code>rule "same-company"
    when
        $p1 : Person($id1 : id)
        $p2 : Person($id2 : id, id &gt; $id1)
    then
        System.out.println($p1.getId() + " " + $p2.getId());
end
</code></pre>

<p>This rule works fine and as expected on its own in a .drl file!</p>

<p>So my questions are: </p>

<ol>
<li><strong>Is this what the spreadsheets are supposed to do?</strong></li>
<li><strong>If not, what could I be doing wrong here?</strong></li>
</ol>

<p>I also have some more complex variables inside Person objects that I'd like to apply logic to (maps of strings for each person that I'd like to compare values of), to which the same thing happens; Drools spreadsheets seem to let a rule pass when the conditions I set have NOT been met. Targeting the opposite is possible, and works, but to me it doesn't seem like that's the way this should work.</p>

<p>Thanks in advance!</p>

<p><hr>
<strong>Edit 1:</strong>
The generated DRL using <a href="https://stackoverflow.com/a/34649384/5347955">Drools - Using “from” in decision table</a> returns the following result:</p>

<pre><code>package org.ps.dtable;
//generated from Decision Table
import org.ps.orm.Person;
// rule values at C12, header at C7
rule "PSBR_12"
    when
        $p1:Person ($id1: id) $p2:Person($id2:id, id &gt; $id1 /*param*/ == "X")
    then
        System.out.println($p1 + " vs " + $p2);
end
</code></pre>

<p>The Excel spreadsheet looks like this:
<img src="https://i.imgur.com/JZHq8Cf.png" alt="Spreadsheet"></p>

<p><strong>Edit 2:</strong>
The $ in <code>/*$param*/</code> was missing, and caused weird evaluation. Lesson learned; never forget about the money.</p>