You are not logged in.
Pages: 1
Hi,
Is it possible to check (from client side - TSQLHttpClient) whether the server uses the same data model?
For example to show message "Please upgrade your server"
Regards
Offline
The "root" parameter in TSQLHttpClient and TSQLRestServer always must be the same, you can use it.
Regards.
Esteban
Offline
@EMartin, can you be more obvious? I don't understand it. Thanks.
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
@edwinsn, is simple:
when you create a, for i.e, TSQLRestServerDB, you does the following:
1) create a server
...
MyModel := TSQLModel.Create([TSQLRecords ...], "root");
MyRestServer := TSQLRestServerDB.Create(MyModel, 'MyDB.db3', false);
...
2) create a client that talk to 1)
...
MyModel := TSQLModel.Create([TSQLRecords ...], "root");
MyClient := TSQLHttpClient.Create(serverhost, serverport, MyModel);
...
Client can talk only with server with same "root", "root" can be any name of course.
I hope that I was clear.
Best regards.
Esteban
Offline
@EMartin,
I guess what juwo wanted to know was what happen if a client connect to a server on which was running on a different "Data Model" in which had slightly different TSQLRecords (different fields, different field type etc.). For example, the server and the clients were all on the version 1.0, and then the server was upgraded to 2.0, but not all of the clients were upgraded to 2.0, thus some of them would be using a different version of "Data Model", is there a way to avoid this situation or it has been guarded by the mORMot already?
Offline
Thanks for the explanation @EMartin. I think @Bo's understand of @juwo's question is correct.
I don't think there are "automatic" ways of that
One idea implementing this:
You set up a global "gDbSchemaVersionNoEach" variable, and each time you upgrade the db schema, you increase that value, and you can expose that version number to the clients via a Method-based API. If you want to store the version number in a sqlite db file, consider the official schema_version PRAGMA (https://www.sqlite.org/pragma.html#prag … ma_version)
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
Sorry for my understood. It's weird for me upgrade the server and not the client, but if the client drive the update (assuming Delphi client) then the client should have the latest version number and compare this with the server version number, for example, after the login you can return the actual server version extending TSQLAuthUser.
Best regards.
Esteban
Esteban
Offline
Thanks a lot for your answers. I applied @edwinsn sugestion: variable and api on server
procedure TNoteServer.Model(Ctxt: TSQLRestServerURIContext);
begin
case Ctxt.Method of
mGET:
Ctxt.ReturnsJson(_ObjFast(['ver', model_ver]));
end;
end;
That works perfectly. Thanks!
@Bo you are correct i would like to avoid problems when not all clients was upgraded, or someone upgrade clients without server
Last edited by juwo (2017-01-13 17:08:51)
Offline
Pages: 1