#1 Re: mORMot 1 » AddOrUpdate returning inconsistent value error » 2015-12-23 13:40:12

The test I did was send a SQL update to a record that does not exist (it was intentional) and as well as in Delphi, I expected that the result of error was 0, but the value I got was a full 12 digits as a value pattern.
In Delphi returns the result 0 because the Delphi IDE already sets the standard zero for this situation, but the Lazarus do not. What would solve parameterizing the result to zero.

//now
function TSQLRest.AddOrUpdate(Value: TSQLRecord): TID;
begin
  if (self=nil) or (Value=nil) then
    result := 0 else
  if Value.fID=0 then
    result := Add(Value,true) else
    if Update(Value) then
      result := Value.fID else
      result := 0;
end;
//After
function TSQLRest.AddOrUpdate(Value: TSQLRecord): TID;
begin
  Result := 0; //for compatibility with Lazarus
  if (self=nil) or (Value=nil) then
    result := 0 else
  if Value.fID=0 then
    result := Add(Value,true) else
    if Update(Value) then //here and where the error occurs
      result := Value.fID else
      result := 0;
end;

#2 mORMot 1 » AddOrUpdate returning inconsistent value error » 2015-12-22 20:22:15

juvencioleite
Replies: 3

Hello, Use the version of FPC 3.1.1 trunk on Linux CentOS 32-bit. And there was the following situation:
I had to use the AddOrUpdate function (mORMot.pas - line 31850) and that the Result default or on exceptions, would need to be 0 or -1 for negative, the value I received was a 12-digit value in the variable type TID. I identified that the Result is not initialized. It was for some reason in specific? If I do not let my contribution. Thank you all.
Ticket UUID:    e0c280430a494aea07dc4cd7727f37adfe0e61a6

Board footer

Powered by FluxBB