You are not logged in.
Pages: 1
Ok, the code.
FModel := TSQLModel.Create([TModelUser]);
VirtualTableExternalRegister(FModel, TModelUser, FOwner.ConnectionProperties);
FServer := TSQLRestServerDB.Create(FModel, SQLITE_MEMORY_DATABASE_NAME);
GetRestServerDb.CreateSQLIndex(TModelUser, ['UserName'], True);
GetRestServerDb.CreateMissingTables;
Where FOwner.ConnectionProperties is a connection property to postgresql server.
When i try to create the index i get:
Project Shell.exe raised exception class ESQLite3Exception with message 'Error SQLITE_ERROR (1) using 3.8.9 - 'no such table: main.ModelUser' extended_errcode=1'.
Is this a known issue?
Thanks in advance.
------
Solved:
Just reverse the last two lines. ;)
Offline
Yes, it does make sense to create the indexes once the tables are created, right?
You should better create the index in TSqlRecord.InitializeTable itself.
This class virtual method will be executed in the proper place, during initialization.
See e.g.
class procedure TSQLArticle.InitializeTable(Server: TSQLRestServer;
const FieldName: RawUTF8; Options: TSQLInitializeTableOptions);
begin
inherited;
if (FieldName='') or (FieldName='PublishedMonth') then
Server.CreateSQLIndex(TSQLArticle,'PublishedMonth',false);
end;
Offline
Sure. I`m just new to mORMot.
Thanks.
Offline
Pages: 1