I've some issues with grouping. Consider the code below which joins two tmp-tables (but it's the same for regular tables).
There are two yellow groupby's. If the first one is enabled the code does not work.
It seems that the position of group by does change the behavior.
Can someone confirm this, and is this correct behavior?
TmpIdRef tmp1, tmp1_res;
TmpIdRef tmp2, tmp2_res;
Query query;
QueryRun queryRun;
QueryBuildDataSource qbdsTmp1;
QueryBuildDataSource qbdsTmp2;
//Fill table1 with one entry
tmp1.Id = 1;
tmp1.insert();
//Fill table 2 with one entry related to table one
tmp2.Id = 2;
tmp2.Parent = tmp1.RecId;
tmp2.insert();
query = new Quey();
qbdsTmp1 = query.addDataSource(tableNum(TmpIdRef));
//qbdsTmp1.addGroupByField(fieldNum(TmpIdRef, RecId)); //This is the problematic line (here it doesnt work);
qbdsTmp1 = qbdsTmp1.addDataSource(tableNum(TmpIdRef));
qbdsTmp1.joinMode(JoinMode::InnerJoin);
qbdsTmp1.addLink(fieldNum(TmpIdRef, RecId), fieldNum(TmpIdRef, Parent));
qbdsTmp1.addGroupByField(fieldNum(TmpIdRef, RecId)); //This is the problematic line (here it works)
queryRun = new QueryRun(query);
queryRun.setCursor(tmp1,1);
queryRun.setCursor(tmp2,2);
while(queryRun.next())
{
tmp1_res = queryRun.getNo(1);
tmp2_res = queryRun.getNo(2);
breakpoint;
}