Skip to content

Commit

Permalink
[DROOLS-7629] Restore correct traversal order when looking for a decl…
Browse files Browse the repository at this point in the history
…aration
  • Loading branch information
mariofusco committed Sep 6, 2024
1 parent 38e7d2f commit 1ae2f8c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private Map<String, Declaration> getAllExtendedDeclaration(RuleImpl rule, Map<St

public Declaration getDeclaration(String identifier) {
// it may be a local bound variable
for (final Iterator<RuleConditionElement> iterator = buildList.descendingIterator(); iterator.hasNext();) {
for (final Iterator<RuleConditionElement> iterator = buildList.iterator(); iterator.hasNext();) {
final Declaration declaration = iterator.next().resolveDeclaration( identifier );
if ( declaration != null ) {
return declaration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,26 @@ public void testNotWithInnerJoin() {
assertThat(results.size()).isEqualTo(1);
assertThat(results.get(0)).isEqualTo("Paris");
}

@Test
public void testNotWithUnification() {
// DROOLS-7629
final String drl =
"package org.drools.compiler.integrationtests.operators;\n" +
"rule R1 when\n" +
" ( not ( $rao_v2 := String() and (\n" +
" $rao_v2 := String()\n" +
" ) ) and (\n" +
" $rao_v2 := String()\n" +
" )\n" +
" )\n" +
"then\n" +
"end";

final KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("not-test", kieBaseTestConfiguration, drl);
final KieSession ksession = kbase.newKieSession();

ksession.insert("test");
assertThat(ksession.fireAllRules()).isEqualTo(0);
}
}

0 comments on commit 1ae2f8c

Please sign in to comment.