[68159 Closed] TDAMemDataTable raises incorrect exception (primary key violation instead of reconcile error)

Hello,
i’ve discovered another problem in Data Abstract. If applying data fails for some reason (for example foreign key failure, primary key failure) and TDAMemDataTable.DetectPKDuplicates property is enabled then an exception “Primary key violation” is raised instead of reconcile error form. Problem is in TDABaseDataAdapter.InternalApplyUpdatesAndThrowFailures method at these lines:

  // step4: ThrowFailures
  lFailedDeltas := TList.Create;
  try
    for i := 0 to lTablesWithDetailsList.Count-1 do
      for j := 0 to TDADataTable(lTablesWithDetails[i]).Delta.Count - 1 do
        if TDADataTable(lTablesWithDetails[i]).Delta.Changes[j].Status = csFailed then
          lFailedDeltas.Add(TDADataTable(lTablesWithDetails[i]).Delta.Changes[j]);

    for i := 0 to lTablesWithDetailsList.Count-1 do
      TDADataTable(lTablesWithDetails[i]).MergeDelta; -- Exception HERE
    ThrowFailures(lTablesWithDetailsList,lFailedDeltas);

Exception is raised in TDADataTable(lTablesWithDetails[i]).MergeDelta so no reconcile form is shown.

I spent whole afternoon on this bug 'cause i had no idea what was happening. In my case, there was only one record in my datatable…i edited this record, tried to apply updates and “primary key violation” was raised. Partially because of that and partially because i’ve another few reported topics with no information from you, i’m running out of patience!
Can you just answer a few of them or tell me what’s happening? I understand you cannot fix everything immediatelly, but i just need to know what will you do with the bug to decide on my next steps.

Here’s the list oh issues that are important for me and i have no reaction for a few months:

Provide me some information of these issues.

Thanks. Jaroslav

Thanks, logged as bugs://68159: TDAMemDataTable raises incorrect exception (primary key violation instead of reconcile error)

Hello,
You wrote:

TDADataTable(lTablesWithDetails[i]).MergeDelta; – Exception HERE

Can you send us a small testcase which reproduces this?

Here’s the list oh issues that are important for me and i have no reaction for a few months:

We will check them.

Hello,

see attached file daSample.zip. It contains one single project, “daSample.dpr”, designed as DA client & server together in one application (using TDALocalDataAdapter), also contains SQLite database file, “PCTrade.sqlite.db”. Compile it and run, then click button “Apply Updates Fail”.

Greetings, Jaroslav

daSample.zip (742.7 KB)

Hello,
Please modify uDADataTable.pas file:

procedure TDADataTable.MergeDelta;
................
  lHasReducedDelta: Boolean;
  oldDetectPk: Boolean; //added
..........................
  oldlog := LogChanges;
  oldDetectPk:= DetectPKDuplicates; //added
  oldmastersource := MasterSource;
.........................
  RemoteUpdatesOptions := RemoteUpdatesOptions-[ruoOnPost];
  LogChanges := False; 
  DetectPKDuplicates := False; //added
.......................
  RemoteUpdatesOptions := oldopt;
  LogChanges := oldlog;
  DetectPKDuplicates := oldDetectPk; //added

bugs://68159 got closed as fixed for release May14 *