You are not logged in.
I made a little sample procedure to illustrate my problem.
The following code works fine on Linux however on Windows I get an exception:"could not convert variant of type (Null) into type (String)"
I am using Lazarus 2.0.10 and the latest mORMot from github
procedure Test();
var connection: TSQLDBSQLite3ConnectionProperties;
V: Variant;
s: String;
begin
connection := TSQLDBSQLite3ConnectionProperties
.create(ExeVersion.ProgramFilePath+'Test.db','','','');
try
with connection.Execute('SELECT strftime(''%H:%M'',datetime(current_timestamp,''localtime'')) as t;',[],@V) do begin
while Step do begin
s := v.t; //could not convert variant of type (Null) into type (String) , only occurs on windows
showMessage(s);
end;
ReleaseRows;
end;
finally
connection.free;
end;
end;
What am I missing?
Offline
I guess you are using FPC 3.2.2.
This sounds like a FPC bug, when you use a late-binding symbol of 1 char only.
See https://synopse.info/forum/viewtopic.php?id=5894
If you use "tim" instead of "t" it should work.
Offline
Thanks.
But that's not it. I'm using FPC 3.2.0
If I use "tim" instead of "t" the problem persists.
Offline
Seems to have something to do with the 'localtime' parameter in the sqlite datetime function.
procedure Test();
var connection: TSQLDBSQLite3ConnectionProperties;
query1, query2: String;
begin
query1 := 'SELECT datetime(current_timestamp,''localtime'');'; //works only on linux
query2 := 'SELECT datetime(current_timestamp);'; //works on linux and windows
connection := TSQLDBSQLite3ConnectionProperties
.create(ExeVersion.ProgramFilePath+'Test.db','','','');
try
with connection.Execute(query1,[]) do begin
if step then showmessage(TimeToStr(ColumnDateTime(0))); //ColumnDateTime(0) returns 0 on windows, works on linux
ReleaseRows;
end;
finally
connection.free;
end;
end;
Any ideas?
Offline
Good finding.
I will investigate.
Update 1: the localtime is not compiled with our SQlite3 because we defined SQLITE_OMIT_LOCALTIME in the compilation script to avoid linking issues.
I will fix it.
Update 2: I have included new localtime32/64() exports as needed by mingw.
A new SQLite3 compilation was needed. So it requires to download some new static binaries.
Offline
It works now, nice!
Thank you.
Offline