2
votes

I have a simple dataset with the following structure:

Server.FieldDefs.Add('Code', ftString, 5);
Server.FieldDefs.Add('Memo', ftMemo, 0);
Server.FieldDefs.Add('Blob', ftBlob, 0);

The Dataset has one record. I then fetch the dataset via TDataSetProvider in a TClientDataSet instance, make changes the data and ApplyUpdate. It shall trigger BeforeUpdateRecord and AfterUpdateRecord event of TDataSetProvider.

However, the ftBlob field's OldValue always show Null but ftMemo and ftString field shows not Null:

OnBeforeUpdateRecord
Code.OldValue is not null
Code.NewValue is not null
Memo.OldValue is not null
Memo.NewValue is not null
Blob.OldValue is null
Blob.NewValue is not null

OnAfterUpdateRecord
Code.OldValue is not null
Code.NewValue is not null
Memo.OldValue is not null
Memo.NewValue is not null
Blob.OldValue is null
Blob.NewValue is not null

Although the ftMemo field doesn't return correct result too. The OldValue of ftMemo field is always an empty string.

I have reported the issue to RSP-15519. A sample project may download from there too.

Just wondering if this is the design of Midas? Or it is a bug?

1
What was the value of the 'Blob' field in the table before the record was edited? I'll bet it was null. Also, you should show us some Delphi code, not your pseudo-code. You're making us guess. - nolaspeaker
see if setting dspropINCLBLOBSINDELTA will do the trick - vavan

1 Answers

0
votes

A TClientDataSet has a built-in property to check whether a blob has been modified:

function BlobIsModified(CDS: TClientDataSet; BlobFieldName: string): Boolean;
begin
  Exit((CDS.Fields.FieldByName(BlobFieldName) as TBlobField).Modified);
end;

We only use this when CDS.Fields.FieldByName(field_name).IsBlob returns True, and CDS.Fields.FieldByName(field_name).DataType is not in [ftString, ftWideMemo, ftWideString], since these string types may be classified as blobs (depending on their size), in which case you should use OldValue, NewValue, and checking for NULL to determine if there has been a change.