Ok I moved the two rules into a process by itself and liked the process to the object's primary form.
I then opened the form and ran the process. I believe this should guarantee the same context for both the find and the count.
Same result, count=6, find = 2.
Here is the file log:
Code: Select all
2009-12-26 08:02:15,578 GENERIC PT#peter -17
2009-12-26 08:02:15,578 GENERIC PT#peter -17
2009-12-26 08:02:15,578 GENERIC PT#peter -20 Executing process tester with parameters: ResultSetRequirement:118
2009-12-26 08:02:15,578 RULE_EVALUATION PT#peter -29 Started evaluation of rules
2009-12-26 08:02:15,578 RULE_EVALUATION PT#peter -22 Evaluating rule 'counter' ResultSetRequirement.CountRSCompleteStepLink=COUNT ExecutionTestStep WHERE (ExecutionTestStep.TestProcedure IN ResultSetRequirement.ParentResultSetReq.ExecutionProcList AND ExecutionTestStep.StepResult IN 'Pass', 'Fail' AND ResultSetRequirement.LinkedRequirement IN ExecutionTestStep.LinkedTestStep.LinkedRequirements)
2009-12-26 08:02:15,578 RULE_EVALUATION PT#peter -2 Adding action ResultSetRequirement.CountRSCompleteStepLink=COUNT ExecutionTestStep WHERE (ExecutionTestStep.TestProcedure IN ResultSetRequirement.ParentResultSetReq.ExecutionProcList AND ExecutionTestStep.StepResult IN 'Pass', 'Fail' AND ResultSetRequirement.LinkedRequirement IN ExecutionTestStep.LinkedTestStep.LinkedRequirements) to the agenda
2009-12-26 08:02:15,578 RULE_EVALUATION PT#peter -16 Finished rule evaluation
2009-12-26 08:02:15,578 RULE_EVALUATION PT#peter -16 Finished evaluation of rules
2009-12-26 08:02:15,578 ACTION_EXECUTION PT#peter -15 Executing action ResultSetRequirement.CountRSCompleteStepLink=COUNT ExecutionTestStep WHERE (ExecutionTestStep.TestProcedure IN ResultSetRequirement.ParentResultSetReq.ExecutionProcList AND ExecutionTestStep.StepResult IN 'Pass', 'Fail' AND ResultSetRequirement.LinkedRequirement IN ExecutionTestStep.LinkedTestStep.LinkedRequirements)
2009-12-26 08:02:15,609 ACTION_EXECUTION PT#peter -5 Value was not changed because it was equal to the old value CountRSCompleteStepLink=6
2009-12-26 08:02:15,609 ACTION_EXECUTION PT#peter -16 Finished executing action ResultSetRequirement.CountRSCompleteStepLink=COUNT ExecutionTestStep WHERE (ExecutionTestStep.TestProcedure IN ResultSetRequirement.ParentResultSetReq.ExecutionProcList AND ExecutionTestStep.StepResult IN 'Pass', 'Fail' AND ResultSetRequirement.LinkedRequirement IN ExecutionTestStep.LinkedTestStep.LinkedRequirements)
2009-12-26 08:02:15,609 RULE_EVALUATION PT#peter -29 Started evaluation of rules
2009-12-26 08:02:15,609 RULE_EVALUATION PT#peter -22 Evaluating rule 'finder' FIND ExecutionTestStep WHERE (ExecutionTestStep.TestProcedure IN ResultSetRequirement.ParentResultSetReq.ExecutionProcList AND ExecutionTestStep.StepResult IN 'Pass', 'Fail' AND ResultSetRequirement.LinkedRequirement IN ExecutionTestStep.LinkedTestStep.LinkedRequirements)
2009-12-26 08:02:15,609 RULE_EVALUATION PT#peter -2 Adding action FIND ExecutionTestStep WHERE ExecutionTestStep.TestProcedure IN ResultSetRequirement.ParentResultSetReq.ExecutionProcList AND ExecutionTestStep.StepResult IN 'Pass', 'Fail' AND ResultSetRequirement.LinkedRequirement IN ExecutionTestStep.LinkedTestStep.LinkedRequirements to the agenda
2009-12-26 08:02:15,609 RULE_EVALUATION PT#peter -16 Finished rule evaluation
2009-12-26 08:02:15,609 RULE_EVALUATION PT#peter -16 Finished evaluation of rules
2009-12-26 08:02:15,609 ACTION_EXECUTION PT#peter -15 Executing action FIND ExecutionTestStep WHERE ExecutionTestStep.TestProcedure IN ResultSetRequirement.ParentResultSetReq.ExecutionProcList AND ExecutionTestStep.StepResult IN 'Pass', 'Fail' AND ResultSetRequirement.LinkedRequirement IN ExecutionTestStep.LinkedTestStep.LinkedRequirements
2009-12-26 08:02:15,671 ACTION_EXECUTION PT#peter -33 Found 2 objects
2009-12-26 08:02:15,671 ACTION_EXECUTION PT#peter -16 Finished executing action FIND ExecutionTestStep WHERE ExecutionTestStep.TestProcedure IN ResultSetRequirement.ParentResultSetReq.ExecutionProcList AND ExecutionTestStep.StepResult IN 'Pass', 'Fail' AND ResultSetRequirement.LinkedRequirement IN ExecutionTestStep.LinkedTestStep.LinkedRequirements
2009-12-26 08:02:15,671 GENERIC PT#peter -16 Finished executing process tester
2009-12-26 08:02:15,671 GENERIC PT#peter -17
2009-12-26 08:02:15,671 GENERIC PT#peter -17
Further to this, I migrated to MySQL because I couldn't work out how to trace the SQL in Derby. I didn't set up all of my data in MySQL, so I didn't replicate the problem, just got a trace of the SQL.
Here are the two queries being executed:
Code: Select all
SELECT COUNT(*) FROM BASTESTDOMAINPT_EXECUTIONTESTSTEP AS ExecutionTestStep LEFT JOIN BASTESTDOMAINPT_EXECUTIONTESTPROCEDURE AS ExecutionTestStep_TestProcedure ON ExecutionTestStep.TestProcedure_RID=ExecutionTestStep_TestProcedure.ID LEFT JOIN BASTESTDOMAINPT_TESTSTEP AS ExecutionTestStep_LinkedTestStep ON ExecutionTestStep.LinkedTestStep_RID=ExecutionTestStep_LinkedTestStep.ID LEFT JOIN BASTESTDOMAINPT_TESTSTEP_REF AS ER_TestStep_ExecutionTestStep_LinkedTestStep_LinkedRequirements ON ExecutionTestStep_LinkedTestStep.ID=ER_TestStep_ExecutionTestStep_LinkedTestStep_LinkedRequirements.ID LEFT JOIN BASTESTDOMAINPT_REQUIREMENT AS ExecutionTestStep_LinkedTestStep_LinkedRequirements ON ER_TestStep_ExecutionTestStep_LinkedTestStep_LinkedRequirements.RID=ExecutionTestStep_LinkedTestStep_LinkedRequirements.ID AND ER_TestStep_ExecutionTestStep_LinkedTestStep_LinkedRequirements.FIELD_NAME='LinkedRequirements' LEFT JOIN BASTESTDOMAINPT_RESULTSET_REF AS ResultSet_ExecutionProcList_RO ON ResultSet_ExecutionProcList_RO.RID=ExecutionTestStep_TestProcedure.ID AND ResultSet_ExecutionProcList_RO.ID=13 AND ResultSet_ExecutionProcList_RO.FIELD_NAME='ExecutionProcList' WHERE ((((ExecutionTestStep_TestProcedure.ID IS NOT NULL AND ResultSet_ExecutionProcList_RO.ID=13)) AND ((ExecutionTestStep.StepResult='Pass' OR ExecutionTestStep.StepResult='Fail'))) AND ((4=ExecutionTestStep_LinkedTestStep_LinkedRequirements.ID AND ExecutionTestStep_LinkedTestStep_LinkedRequirements.ID IS NOT NULL)))
SELECT ExecutionTestStep.* FROM BASTESTDOMAINPT_EXECUTIONTESTSTEP AS ExecutionTestStep LEFT JOIN BASTESTDOMAINPT_EXECUTIONTESTPROCEDURE AS ExecutionTestStep_TestProcedure ON ExecutionTestStep.TestProcedure_RID=ExecutionTestStep_TestProcedure.ID LEFT JOIN BASTESTDOMAINPT_TESTSTEP AS ExecutionTestStep_LinkedTestStep ON ExecutionTestStep.LinkedTestStep_RID=ExecutionTestStep_LinkedTestStep.ID LEFT JOIN BASTESTDOMAINPT_TESTSTEP_REF AS ER_TestStep_ExecutionTestStep_LinkedTestStep_LinkedRequirements ON ExecutionTestStep_LinkedTestStep.ID=ER_TestStep_ExecutionTestStep_LinkedTestStep_LinkedRequirements.ID LEFT JOIN BASTESTDOMAINPT_REQUIREMENT AS ExecutionTestStep_LinkedTestStep_LinkedRequirements ON ER_TestStep_ExecutionTestStep_LinkedTestStep_LinkedRequirements.RID=ExecutionTestStep_LinkedTestStep_LinkedRequirements.ID AND ER_TestStep_ExecutionTestStep_LinkedTestStep_LinkedRequirements.FIELD_NAME='LinkedRequirements' LEFT JOIN BASTESTDOMAINPT_RESULTSET_REF AS ResultSet_ExecutionProcList_RO ON ResultSet_ExecutionProcList_RO.RID=ExecutionTestStep_TestProcedure.ID AND ResultSet_ExecutionProcList_RO.ID=13 AND ResultSet_ExecutionProcList_RO.FIELD_NAME='ExecutionProcList' WHERE ((((ExecutionTestStep_TestProcedure.ID IS NOT NULL AND ResultSet_ExecutionProcList_RO.ID=13)) AND ((ExecutionTestStep.StepResult='Pass' OR ExecutionTestStep.StepResult='Fail'))) AND ((4=ExecutionTestStep_LinkedTestStep_LinkedRequirements.ID AND ExecutionTestStep_LinkedTestStep_LinkedRequirements.ID IS NOT NULL))) FOR UPDATE
They are almost identical, but I think the problem is that you are counting all returned rows which could be problematic when the cartesian joins expands the rows beyond the number of primary elements.
I believe the answer may be to perform a SELECT COUNT(DISTINCT ExecutionTestStep.ID) FROM ....
I think I came across this issue previously but was too lazy to dig into it at the time.
I could be completely wrong of course. I'd know for sure if you could tell me how to see and execute SQL in Derby.
Cheers and Merry Christmas.
Peter