You are not logged in.
Setting up the server with authorization doesn't work as expected.
I expected the two tables would be created automatically when I set the parameter of "TSQLRestServerDB.Create" to true.
The table "Ticket" is created
constructor TTicketServer.create;
begin
TDDDRepositoryRestFactory.ComputeSQLRecord([TTicket]);
DBConnect(rseZeosMySQL, 'zdbc:mysql://localhost:3306', 'test_mormot', 'root', '');
Model := CreateTicketModel;
VirtualTableExternalRegister(Model, [TTicket], Props);
DBServer := TSQLRestServerDB.Create(Model, true); // Require authorization
try
DBServer.CreateMissingTables(0);
DBServer.ServiceContainer.InjectResolver([TInfraRepoTicketFactory.create(DBServer)], true);
DBServer.ServiceDefine(TInfraRepoTicket, [IDomTicketCommand], sicClientDriven);
httpServer := TSQLHttpServer.Create(PORT_NAME, [DBServer], '+', HTTP_DEFAULT_MODE);
function createTicketModel: TSQLModel;
begin
result := TSQLModel.Create([TTicket],'root');
end;
procedure TTicketServer.DBConnect(aEngine: TRemoteSQLEngine; const aServerName,
aDatabaseName, aUserID, aPassWord: RawUTF8);
const
TYPES: array[TRemoteSQLEngine] of TSQLDBConnectionPropertiesClass = (TSQLDBZEOSConnectionProperties,TOleDBConnectionProperties, TODBCConnectionProperties, TSQLDBOracleConnectionProperties, TSQLDBSQLite3ConnectionProperties, nil, TOleDBMSSQL2008ConnectionProperties);
begin
if Props <> nil then
raise Exception.Create('Connect called more than once');
if TYPES[aEngine] = nil then
raise Exception.CreateFmt('aEngine=%s is not supported', [GetEnumName(TypeInfo(TRemoteSQLEngine), ord(aEngine))^]);
Props := TYPES[aEngine].Create(aServerName, aDatabaseName, aUserID, aPassWord);
end;
What am I missing?
Last edited by larand54 (2019-04-22 14:41:29)
Delphi-11, WIN10
Offline
Include TSQLAuthUser and TSQLAuthGroup in your database model, something like:
TSQLModel.Create([TTicket, TSQLAuthUser, TSQLAuthGroup],'root');
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
I have already tested that and I did it again but only the ticket.table is created.
I'm using fpc, zeos and lazarus and I have had a lot of problems making it work can it be something with this configuration? I've tested with delphi in another project and that was easier but then I also used MSSQL.
Last edited by larand54 (2019-04-22 21:04:57)
Delphi-11, WIN10
Offline
I actually declaring a classes inheriting from TSQLAuthUser/Group and add it to the model, but what you did should also work.
I'm using Delphi only, with sqlite db. maybe you can debug into the CreateMissingTables method.
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
As I understand your call CreateMissingTables(0) means database schema is not modified. Try to use just DBServer.CreateMissingTables;
Alexander
Offline
ianxevcd, I tried that before and I tried again - it didn't change anything. The parameter I used is, as what I understand, just a version number. Don't know where it is used but as my ticket table is created with or without this parameter, I can't see that it have something with db modification to do. But what do I know?
I will try to debug that function a bit more later on if no other solution comes up.
Delphi-11, WIN10
Offline
I found the missing part myself. I had to put all tables in the "VirtualTableExternalRegister" procedure.
I was fooled by the fact that you didn't need to put these tables (TSQLAuthUser, TSQLAuthGroup) into the model as do that automatically in the background, so I never thought about putting these tables into the VirtualTableExternalRegister procedure.
VirtualTableExternalRegister(Model, [TTicket, TSQLAuthUser, TSQLAuthGroup], Props);
Delphi-11, WIN10
Offline