Null in MemoField to Variant

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
mariot
Posts: 17
Joined: Mon 02 Feb 2015 11:35

Null in MemoField to Variant

Post by mariot » Mon 27 Jan 2020 08:49

Hi,

When we used UniDAC 7.3.10, then with using TDataSet.FieldByName MySQL returns correctly Null value in column COLUMN_DEFAULT in table INFORMATION_SCHEMA.COLUMNS. With new UniDAC 8.1.2 is returned empty string - it is bad value.

I look at more deep, and see that problem is probably in method:

Code: Select all

function TWideMemoField.GetAsVariant: Variant;
begin
  Result := GetAsString;
end;
GetAsString return always string - but I expect Null value as Result of GetAsVariant method.

I assume it's a bug.

Now, in our code, i use workaround:

Code: Select all

// Result is Variant
  Field := (Dataset as TDataset).FieldByName(FieldName);
  if Field.IsNull then
    Result := Null
  else
    Result := Field.Value;
Regards,

Mario

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Null in MemoField to Variant

Post by ViktorV » Mon 27 Jan 2020 13:58

This behavior originates from the specifics of the IDE functionality, not UniDAC. When you call the AsVariant method in a descendant class of TField, the implementation defined in the DB unit is called. You can see it for yourself by running your example in RAD Studio 10.2 -- you'll get the exact same result in UniDAC 7.3.10 and UniDAC 8.1.2.
Note that in RAD Studio 10.3, this method was implemented correctly.

mariot
Posts: 17
Joined: Mon 02 Feb 2015 11:35

Re: Null in MemoField to Variant

Post by mariot » Mon 27 Jan 2020 19:19

Oh, I understand. It is not problem in UniDAC. Thanks for answer.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Null in MemoField to Variant

Post by ViktorV » Tue 28 Jan 2020 10:18

Thank you for the interest to our product.
It is good to see that the problem has been solved.
If you have any questions during using our products, please don't hesitate to contact us - and we will try to help you solve them.

Post Reply