2

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?

Chau Chee Yang
  • 18,422
  • 16
  • 68
  • 132

1 Answers1

0

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.

James L.
  • 9,384
  • 5
  • 38
  • 77