UniDAC 7.4.12 Could not convert variant of type (Null) into type (Double)

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Alexey Afrosin
Posts: 2
Joined: Wed 03 Jul 2019 13:45

UniDAC 7.4.12 Could not convert variant of type (Null) into type (Double)

Post by Alexey Afrosin » Wed 03 Jul 2019 14:22

Hi!

I am Using UniDAC 7.4.12 with Sqlite 3.27.2.
When I open Query I get error : Could not convert variant of type (Null) into type (Double)

Code: Select all

procedure TForm2.Button1Click(Sender: TObject);
begin
  UniQuery1.Open;
end;
Before UniDAC I am using LiteDac 2.6.21 and this error don`t occurred.

Field mapping not acceptable in this case.

How I can fix it?

Tarifer
Posts: 26
Joined: Thu 26 May 2011 08:13

Re: UniDAC 7.4.12 Could not convert variant of type (Null) into type (Double)

Post by Tarifer » Thu 04 Jul 2019 08:37

Hello!
I got the same error/
I check the sources and found:

Code: Select all

unit LiteClassesUni;
...
procedure TSQLiteConnection.RegisterInternalFunctions;
begin
...
  TSQLiteFunctionManager(FunctionManager).RegisterFunction('ROUND', 2, InternalRound);
end;
...
procedure TSQLiteConnection.InternalRound(InValues: array of Variant; var ResultValue: Variant);
begin
  ResultValue := Round(double(InValues[0]) * Power(10, InValues[1])) / Power(10, InValues[1]);
end;
procedure TSQLiteConnection.InternalRound should check, if any values is NULL, and returns NULL in this case:

Code: Select all

procedure TSQLiteConnection.InternalRound(InValues: array of Variant; var ResultValue: Variant);
begin
  if VarIsNull(InValues[0]) or VarIsNull(InValues[1]) then
    ResultValue := Null
  else
    ResultValue := Round(double(InValues[0]) * Power(10, InValues[1])) / Power(10, InValues[1]);
end;
DevArt, please, fix this and similar functions.
Or make the way to disable redefining native functions.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: UniDAC 7.4.12 Could not convert variant of type (Null) into type (Double)

Post by MaximG » Thu 04 Jul 2019 13:36

Thank you for the information. We will investigate the described issue and let you know the results shortly.

Alexey Afrosin
Posts: 2
Joined: Wed 03 Jul 2019 13:45

Re: UniDAC 7.4.12 Could not convert variant of type (Null) into type (Double)

Post by Alexey Afrosin » Fri 05 Jul 2019 12:14

If you need examples, I can provide them

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: UniDAC 7.4.12 Could not convert variant of type (Null) into type (Double)

Post by MaximG » Fri 05 Jul 2019 14:53

Please send us a test project via the e-support form on our website: https://www.devart.com/company/contactform.html

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: UniDAC 7.4.12 Could not convert variant of type (Null) into type (Double)

Post by MaximG » Fri 19 Jul 2019 09:08

We've reproduced the issue and fixed it. The fix will be included in the new UniDAC build, which we're planning to release next week.

Post Reply