Hello,
I have discovered a problem with cloned data tables in Data Abstract. If I do an remote update/add utilising AppendMode and the server gives only one record, there is a problem if any clone is closed or any clone is a detail with no records for the current master.
I have prepared a sample project to demonstrate the problem. Button TEST1 triggers the situation with clone used as a detail. Button TEST2 triggers the situation with a closed clone.
daSample.zip (84.5 KB)
I think that problem can be (hot)fixed in uDAMemDataSet.pas unit, inside of local function TDAMemoryDataset.AddRecordsfromList.isRowUpdate, see this:
function isRowUpdate(aTable: TDAMemoryDataset; var abuf:PMemDatasetrecord):Boolean;
var
lIndex: TDAMemIndex;
ltempIndex:Boolean;
i: Integer;
llist: TList;
ltable: TDAMemoryDataset;
begin
Result := False;
abuf := nil;
if FCloneClientList <> nil then begin
llist := FCloneClientList.LockList;
try
for i:=0 to llist.Count -1 do begin
ltable := TDAMemoryDataset(llist[i]);
/// <FIX_HERE>
if ltable.IsEmpty then Continue;
/// </FIX_HERE>
lIndex := SearchIndex_Direct(lTable);
ltempIndex := lIndex = nil;
if ltempIndex then begin
lIndex := TDAMemIndex.Create(lTable);
lIndex.Init(ACallbackRecord^.PK,False,False);
lIndex.FInitFromIndexDef:= False;
end;
try
Result := lIndex.CompareValues_Index(RecBuf_To_MemDatasetRecord(lTable.ActiveBuffer),PMemDatasetrecord_Native(AList[0])) = 0;
if Result then begin
abuf := PMemDatasetrecord(RecBuf_To_MemDatasetRecord(lTable.ActiveBuffer));
Break;
end;
finally
if ltempIndex then lIndex.Free;
end;
end;
finally
aTable.FCloneClientList.UnlockList;
end;
end;
end;
Regards from Prague,
Jaroslav