You are not logged in.
Pages: 1
Hi @AB
I updated Mormot, Now works as expected.
Great thanks to you and good day
@AB:
I changes this line (mormot.rest.server line#3514):
sql := fCall^.InBody;
TO:
sql:='select id from note';
and it works, Do have an idea what to do?
And I checked that in (mormot.rest.core) When I try to send a request by the client the Call.InBody is empty !!
constructor TRestUriContext.Create(const aCall: TRestUriParams);
begin
fCall := @aCall;
fMethod := ToMethod(aCall.Method);
if aCall.InBody <> '' then //<---- empty !!!!
aCall.InBodyType(fInputContentType, {guessjsonifnone=}false);
end;
The inBody is empty:
[image]https://imgtr.ee/images/2023/06/20/ZYN3X.png[/image]
And access rights has [reSQL]
....
// GET with a sql statement sent as UTF-8 body (not 100% HTTP compatible)
sql := fCall^.InBody;
if sql <> '' then//<-------sql is empty
begin
sqlisselect := IsSelect(pointer(sql), @sqlselect);
if sqlisselect or
(reSql in fCall^.RestAccessRights^.AllowRemoteExecute) then
begin
fStaticOrm := nil;
....
Hi @AB
Trying to get a few records (for test)
Client:
aList:=Client.RetrieveList(TNote,'body','id<?',[5]);
[image]https://imgtr.ee/images/2023/06/20/ZYD8n.png[/image]
Hello mormot,
My Server based on Mormot 2, and Client (cross-platform) using Mormot 1.
Model := TSQLModel.Create([TNote],'root');
DB := TSQLRestServerDB.Create(Model,ChangeFileExt(paramstr(0),'.db3'),true);//enable auth.
DB.DB.LockingMode:=lmExclusive;
DB.DB.Synchronous:=smOff;
DB.CreateMissingTables;
Server := TSQLHttpServer.Create('8080',[DB],'+',useHttpApiRegisteringURI);
Server.AccessControlAllowOrigin := '*'; // allow cross-site AJAX queries
When I try to get one record it works and when I want to get a list (all of records for example) I got error 400 !
procedure TForm1.Button1Click(Sender: TObject);
var
Model:TSQLModel;
Client:TSQLRestClientHTTP;
rec : TNote;
aList:TObjectList;
x:TObjectList<TNote>;
begin
Model:=TSQLModel.Create([TNote],'root');
Client:=TSQLRestClientHTTP.Create('x.x.x.x',8080,Model,false);
if not Client.SetUser(TSQLRestServerAuthenticationDefault,'Admin','synopse',false) then
begin
//.......
end;
if (not Client.Connect) or (Client.ServerTimeStamp=0) then
begin
//......
end
//get one record works
rec := TNote.Create (Client,1);
//this also works
Client.Retrieve(1,rec);
x:=Client.RetrieveList<TNote>('id,body','',[]);
x.count <--- zero
end;
Error 400 is the status of the request as I debug it here (syncrossplatfromrest.pas):
Call.Init(Model.Root+UrlEncode(['sql',sql]),'GET','');
URI(Call);
if Call.OutStatus=HTTP_SUCCESS then begin//<--- here
........
Any idea :-)
@AB when you think it will be supported under Mormot2?
I hosted my Server in Remote VPS and it now takes ~552 ms.
When I run my clint it took more than 2s to insert one record!
How can I make it faster?
Server: localhost
Client: on the same computer (local)
Server:
procedure TForm1.FormCreate(Sender: TObject);
begin
Model := TSQLModel.Create([TNote],'root');
DB := TSQLRestServerDB.Create(Model,ChangeFileExt(paramstr(0),'.db3'));
DB.CreateMissingTables;
Server := TSQLHttpServer.Create('8080',[DB],'+',useHttpApiRegisteringURI);
Server.AccessControlAllowOrigin := '*'; // allow cross-site AJAX queries
end;
Client:
begin
aModel := TSQLModel.Create([TNote],'root');;
try
aClient := TSQLHttpClientWinHTTP.Create('localhost','8080',aModel);
try
writeln('Add a new TPerson');
timer.Start;
aPerson := TNote.Create;
try
Randomize;
aPerson.Body := 'eliaasoooo'+Int32ToUtf8(Random(10000000));
aID := aClient.Add(aPerson,true);
finally
aPerson.Free;
end;
writeln('Processed in ',Ansi7ToString(Timer.Stop));
writeln('Added TPerson.ID=',aID);
aPerson := TNote.Create(aClient,aID);
try
writeln('Name read for ID=',aPerson.ID,' from DB = "',aPerson.Body,'"');
finally
aPerson.Free;
end;
finally
aClient.Free;
end;
write(#10'Press [Enter] to quit');
readln;
finally
aModel.Free;
end;
end.
Using Postman -> post -> 41ms
Thank you AB, now works fine
Hello every one
When I create my client as VCL App. I got this error: TForm1 is not part of TSQLMODEL root
When I create my client as console App. it works just fine.
What do I miss here?
Delphi 10.4.2
Mormot 1 2023
Pages: 1