You are not logged in.
Pages: 1
Hi AB
function TSQLRest.Add(Value: TSQLRecord; SendData: boolean;
ForceID: boolean=false): integer;
var JSONValues: RawUTF8;
TableIndex: integer;
begin
if Value=nil then begin
result := 0;
exit;
end;
TableIndex := Model.GetTableIndexExisting(PSQLRecordClass(Value)^);
if SendData then begin
Value.ComputeFieldsBeforeWrite(self,seAdd); // update TModTime/TCreateTime fields
if Model.TableProps[TableIndex].Kind in INSERT_WITH_ID then
ForceID := true;
JSONValues := Value.GetJSONValues(true, // true=expanded
(Value.fID<>0) and ForceID,soInsert);
end else
JSONValues := '';
// on success, returns the new ROWID value; ************************ on error, returns 0 **************************
result := EngineAdd(TableIndex,JSONValues); // will call static
// on success, Value.ID is updated with the new ROWID
Value.fID := result;
if SendData then ********************* result not checked maybe better: if SendData and (result<>0) then ?
fCache.Notify(PSQLRecordClass(Value)^,result,JSONValues,soInsert);
end;
Not a bug, but
EngineAdd on error, returns 0
but not checked
Offline
Yes, this is by design.
It is to the client to check that ID is not 0.
You are right: it should be checked for the cache update.
Should be fixed by http://synopse.info/fossil/info/143a5a8209
Thanks for the feedback
Offline
Pages: 1