You are not logged in.
Hi Arnaud,
there's an issue with TSQLRecordMany.ManyAdd() when used via TSQLRestBatch.
Current code:
function TSQLRecordMany.ManyAdd(aClient: TSQLRest; aSourceID, aDestID: TID;
NoDuplicates: boolean; aUseBatch: TSQLRestBatch): boolean;
begin
result := false;
if (self=nil) or (aClient=nil) or (aSourceID=0) or (aDestID=0) or
(fSourceID=nil) or (fDestID=nil) then
exit; // invalid parameters
if NoDuplicates and
(InternalIDFromSourceDest(aClient,aSourceID,aDestID)<>0) then
exit; // this TRecordReference pair already exists
fSourceID^ := aSourceID;
fDestID^ := aDestID;
if aUseBatch<>nil then
result := aUseBatch.Add(self,true)<>0 else // Issue here
result := aClient.Add(self,true)<>0;
end;
aUseBatch.Add returns the batch index or -1 on error, but code is checking for <> 0, so its always false for the 1st element.
Fix:
function TSQLRecordMany.ManyAdd(aClient: TSQLRest; aSourceID, aDestID: TID;
NoDuplicates: boolean; aUseBatch: TSQLRestBatch): boolean;
begin
result := false;
if (self=nil) or (aClient=nil) or (aSourceID=0) or (aDestID=0) or
(fSourceID=nil) or (fDestID=nil) then
exit; // invalid parameters
if NoDuplicates and
(InternalIDFromSourceDest(aClient,aSourceID,aDestID)<>0) then
exit; // this TRecordReference pair already exists
fSourceID^ := aSourceID;
fDestID^ := aDestID;
if aUseBatch<>nil then
result := aUseBatch.Add(self,true)<>-1 else // Fix
result := aClient.Add(self,true)<>0;
end;
Could you apply this fix to current sources please?!
Thanks,
oz.
Offline
@ab: is there any chance to apply this little fix?
Offline
Please check https://synopse.info/fossil/info/9deb91e6c9
Sorry for the delay.
Offline
Thanks Arnaud!
Offline