You are not logged in.
We've created a unittest setting up a RestServer and a RestClient, when we start a batch on the client, and immediately after issue BatchSend the return value is 400 ...
procedure TLCSServerSessionTestBase.TestEmptyBatchSend;
var
Ida: TIntegerDynArray;
begin
Check(SQLWorkbaseRestClient.BatchStart(TSQLWorkbaseObject),'BatchStart failed');
CheckEquals(HTML_SUCCESS,SQLWorkbaseRestClient.BatchSend(Ida),'Empty BatchSend failed'); // FAILS, RETURN VALUE = 400
end;
This same thing happens when we use Http, NamedPipe, or Messages
Is this designed behavior? We would think that sending an empty batch is not an error, even though it is not very efficient ;-)
[Edit]
I added a new Test to TTestExternalDatabase.CryptedDatabase, and this one fails too!
Client2 := TSQLRestClientDB.Create(Model,nil,'testpass.db3',TSQLRestServerDB,false,password);
try
Client2.Server.DB.Synchronous := smOff;
Client2.Server.DB.WALMode := true;
Client2.Server.CreateMissingTables;
Check(Client2.TransactionBegin(TSQLRecordPeople));
Check(Client2.BatchStart(TSQLRecordPeople));
while False do begin
Check(R.ID<>0);
Check(Client2.BatchAdd(R,true)>=0);
end;
Check(Client2.BatchSend(Res)=200);
Client2.Commit;
finally
Client2.Free;
end;
Last edited by Bascy (2012-10-16 11:41:39)
Offline
TSQLRestClientURI.BatchSend() really cannot cope with empty Batches, so I guess an enhancement is needed here:
Line 17810:
...
try
if fBatchCount = 0 then begin // Nothing to send
result := HTML_SUCCESS;
exit;
end;
fBatch.CancelLastComma;
...
Offline
Thanks for the report.
Offline
Thanks for the fix!
Why not add a unittest for this particular problem so the test will ensure it will keep working in the future:
Synselftest.pas, line 4400
Client2 := TSQLRestClientDB.Create(Model,nil,'testpass.db3',TSQLRestServerDB,false,password);
try
Client2.Server.DB.Synchronous := smOff;
Client2.Server.DB.WALMode := true;
Client2.Server.CreateMissingTables;
Check(Client2.TransactionBegin(TSQLRecordPeople));
Check(Client2.BatchStart(TSQLRecordPeople));
Check(Client2.BatchSend(Res)=200);
Client2.Commit;
finally
Client2.Free;
end;
Offline
Good idea.
See http://synopse.info/fossil/info/1849604e76
Offline