Page 1 of 1

Null in MemoField to Variant

Posted: Mon 27 Jan 2020 08:49
by mariot
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

Re: Null in MemoField to Variant

Posted: Mon 27 Jan 2020 13:58
by ViktorV
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.

Re: Null in MemoField to Variant

Posted: Mon 27 Jan 2020 19:19
by mariot
Oh, I understand. It is not problem in UniDAC. Thanks for answer.

Re: Null in MemoField to Variant

Posted: Tue 28 Jan 2020 10:18
by ViktorV
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.