Skip to content
Permalink
Browse files

fixed long-standing ORM random bug when retrieving data from the data…

…base

- thanks Alan for the feedback!
  • Loading branch information
Arnaud Bouchez
Arnaud Bouchez committed Nov 26, 2019
1 parent 618fbac commit 83a13ee4cd57005c9cf4557dd8cdda6d29476843
Showing with 9 additions and 4 deletions.
  1. +2 −1 SQLite3/mORMotSQLite3.pas
  2. +6 −2 SynSQLite3.pas
  3. +1 −1 SynopseCommit.inc
@@ -1378,7 +1378,8 @@ function TSQLRestServerDB.MainEngineList(const SQL: RawUTF8; ForceAJAX: Boolean;
function TSQLRestServerDB.MainEngineRetrieve(TableModelIndex: integer; ID: TID): RawUTF8;
var aSQL: RawUTF8;
begin
if (ID<0) or (TableModelIndex<0) or (result<>'') then
result := '';
if (ID<0) or (TableModelIndex<0) then
exit;
with Model.TableProps[TableModelIndex] do
FormatUTF8('SELECT % FROM % WHERE RowID=:(%):;',
@@ -4210,8 +4210,10 @@ function TSQLDataBase.ExecuteJSON(const aSQL: RawUTF8; Expand: boolean=false;
Count: PtrInt;
Timer: TPrecisionTimer;
begin
if self=nil then
if self=nil then begin
result := '';
exit; // avoid GPF in case of call from a static-only server
end;
Timer.Start;
result := LockJSON(aSQL,aResultCount); // lock and try getting the request from the cache
if result='' then // only Execute the DB request if not got from cache
@@ -4375,8 +4377,10 @@ procedure TSQLDataBase.UnLock;

function TSQLDataBase.LockJSON(const aSQL: RawUTF8; aResultCount: PPtrInt): RawUTF8;
begin
if self=nil then
if self=nil then begin
result := '';
exit; // avoid GPF in case of call from a static-only server
end;
fSafe.Lock; // cache access is also protected by fSafe
try
if IsCacheable(aSQL) then begin
@@ -1 +1 @@
'1.18.5479'
'1.18.5480'

0 comments on commit 83a13ee

Please sign in to comment.
You can’t perform that action at this time.