Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Missing deleted records in TFDJSONDeltas


This question is answered.


Permlink Replies: 4 - Last Post: Mar 21, 2017 7:22 AM Last Post By: Murilo Costa
Davide Rubbiani

Posts: 70
Registered: 8/15/03
Missing deleted records in TFDJSONDeltas  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 19, 2015 9:38 AM
Hello,

I'm working on a REST powered FireDAC project with XE8.
I need to manually apply updates on the server side so I decide to use the TFDJSONDeltas sent by my client application to inspect changed records one by one and manually save them on the database.

The problem is in datasets contained in TFDJSONDeltas I found inserted and modified record but not the deleted ones ?

Following the code I'm using in the client application to get the Deltas :

function TMainDataModule.GetDeltas: TFDJSONDeltas;
begin
if (TblOrders.State in dsEditModes) then
TblOrders.Post;

if (TblOrderItems.State in dsEditModes) then
TblOrderItems.Post;

Result := TFDJSONDeltas.Create;

TblOrders.FilterChanges := [rtModified, rtInserted, rtDeleted];
TblOrderItems.FilterChanges := [rtModified, rtInserted, rtDeleted];
try
TFDJSONDeltasWriter.ListAdd(Result, DsOrders, TblOrders);
TFDJSONDeltasWriter.ListAdd(Result, DsOrderItems, TblOrderItems);
finally
TblOrders.FilterChanges := [rtModified, rtInserted, rtUnmodified];
TblOrderItems.FilterChanges := [rtModified, rtInserted, rtUnmodified];
end;
end;



And here the code I'm using in the server application to assign the Delta datasets to two local TFDMemTable I'm using to inspect changed records :


procedure TAgentiServerMethods.ApplyOrderUpdates(const ADeltaList: TFDJSONDeltas; const AUserId: Integer);
var
DataSet: TFDDataSet;

DataSet := TFDJSONDeltasReader.GetListValueByName(ADeltaList, DsOrders);
TblOrderChanges.AppendData(DataSet);
TblOrderChanges.FilterChanges := [rtModified, rtInserted, rtDeleted];

DataSet := TFDJSONDeltasReader.GetListValueByName(ADeltaList, DsOrderItems);
TblOrderItemsChanges.AppendData(DataSet);
TblOrderItemsChanges.FilterChanges := [rtModified, rtInserted, rtDeleted];


What I'm doing wrong ?

Thank you,
Davide

Edited by: Davide Rubbiani on May 19, 2015 10:10 AM
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: Missing deleted records in TFDJSONDeltas
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 23, 2015 12:05 AM   in response to: Davide Rubbiani in response to: Davide Rubbiani
I contacted the TFDJSONDeltas developer and he was not able to reproduce the issue.
He would continue to analyze the issue if you will provide test project, reproducing the issue.

--
With best regards,
Dmitry Arefiev / FireDAC Architect
Davide Rubbiani

Posts: 70
Registered: 8/15/03
Re: Missing deleted records in TFDJSONDeltas  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 24, 2015 11:55 PM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
Hello Dmitry,

preparing the test project you ask me I found an error in my code that was the cause I didn't find deleted record in delta packets.

TFDJSONDeltas works as expected!

Sorry for my wrong notification,
Davide

Dmitry Arefiev wrote:
I contacted the TFDJSONDeltas developer and he was not able to reproduce the issue.
He would continue to analyze the issue if you will provide test project, reproducing the issue.

--
With best regards,
Dmitry Arefiev / FireDAC Architect
Murilo Costa

Posts: 3
Registered: 8/5/07
Re: Missing deleted records in TFDJSONDeltas  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 20, 2017 4:51 PM   in response to: Davide Rubbiani in response to: Davide Rubbiani
What was wrong?
I'm going through this right now.
Davide Rubbiani wrote:
Hello Dmitry,

preparing the test project you ask me I found an error in my code that was the cause I didn't find deleted record in delta packets.

TFDJSONDeltas works as expected!

Sorry for my wrong notification,
Davide

Dmitry Arefiev wrote:
I contacted the TFDJSONDeltas developer and he was not able to reproduce the issue.
He would continue to analyze the issue if you will provide test project, reproducing the issue.

--
With best regards,
Dmitry Arefiev / FireDAC Architect
Murilo Costa

Posts: 3
Registered: 8/5/07
Re: Missing deleted records in TFDJSONDeltas  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 21, 2017 7:22 AM   in response to: Murilo Costa in response to: Murilo Costa
I found the error.

I have to change the FilterChanges of DataSet before use appenddata on memtable

Murilo Costa wrote:
What was wrong?
I'm going through this right now.
Davide Rubbiani wrote:
Hello Dmitry,

preparing the test project you ask me I found an error in my code that was the cause I didn't find deleted record in delta packets.

TFDJSONDeltas works as expected!

Sorry for my wrong notification,
Davide

Dmitry Arefiev wrote:
I contacted the TFDJSONDeltas developer and he was not able to reproduce the issue.
He would continue to analyze the issue if you will provide test project, reproducing the issue.

--
With best regards,
Dmitry Arefiev / FireDAC Architect
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02