heh, I made a mistake with the rule ( Location(z, y;) and ?hasFood(x, z;) ) should be ( Location(z, y;) and hasFood(x, z;) )
Otherwise it's not reactive, and then ordering matters. With that change I can do the insertions in any order and all is fine. Mark On 22/06/2011 19:30, Mark Proctor wrote: > ok I managed to re-create the test with: > "package org.drools.test \n" + > > "import java.util.List\n" + > "import java.util.ArrayList\n" + > > "global List list\n" + > > "dialect \"mvel\"\n" + > > "declare Person\n" + > " name : String\n" + > " likes : String\n" + > "end\n" + > "\n" + > "declare Location\n" + > " thing : String \n" + > " location : String \n" + > "end\n" + > "\n" + > "declare Edible\n" + > " thing : String\n" + > "end\n" + > "\n" + > "\n" + > "query hasFood( String x, String y ) \n" + > " Location(x, y;) " + > " or \n " + > " ( Location(z, y;) and ?hasFood(x, z;) )\n"+ > "end\n" + > "\n" + > "rule look when \n" + > " Person( $l : likes ) \n" + > " hasFood( $l, 'kitchen'; )\n" + > "then\n" + > " list.add( 'kitchen has ' + $l );" + > "end\n" + > "rule go1 when\n" + > " String( this == 'go1') \n" + > "then\n" + > " insert( new Person('zool', 'peach') );\n" + > " insert( new Location(\"table\", \"kitchen\") );\n" + > " insert( new Location(\"peach\", \"table\") );\n" + > "end\n" + > "\n"; > > On 22/06/2011 18:25, Mark Proctor wrote: >> On 22/06/2011 16:39, Wolfgang Laun wrote: >>> This is related to the example in 2.1.2.8., Backward Chaining. >>> >>> Using the same rules and queries given there, the sequence of fact >>> insertions >>> >>> insert( new Here( "table" ) ); >>> insert( new Edible( "peach" ) ); >>> insert( new Location( "peach", "table" ) ); >>> >>> results in nothing being seen and nothing being edible, whereas >>> >>> insert( new Edible( "peach" ) ); >>> insert( new Location( "peach", "table" ) ); >>> insert( new Here( "table" ) ); >>> >>> results in the obvious and expected result. >>> >>> There is no difference w.r.t. using '?' in front of query names. >> Take a look at the tests here, see if you can add the logic that you >> think should works and doesn't and let us know. As far as I know >> insertion order should not matter: >> https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/integrationtests/BackwardChainingTest.java >> >> Mark >>> -W >>> >>> _______________________________________________ >>> rules-dev mailing list >>> rules-dev@lists.jboss.org >>> https://lists.jboss.org/mailman/listinfo/rules-dev >>> >>> >> _______________________________________________ >> rules-dev mailing list >> rules-dev@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-dev >> >> > > _______________________________________________ > rules-dev mailing list > rules-dev@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-dev > > _______________________________________________ rules-dev mailing list rules-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-dev