You are not logged in.
I have some class inherits:
TSQLMyTable = class(TSQLRecord)
private
...
published
...
end;
TSQLMyTableA = class(TSQLMyTable)
private
...
published
...
end;
TSQLMyTableB = class(TSQLMyTable)
private
...
published
...
end;
I create a model depends on used DB:
if ... then
FModel := TSQLModel.Create([TSQLMyTableA])
else
FModel := TSQLModel.Create([TSQLMyTableB]);
Then I call VirtualTableExternalRegister and register table as "MyTable" in any case. So in ORM level I can access only to the base fields from TSQLMyTable. But also I can excec some direct sql requests with optimisations for different DB using custom fields from TSQLMyTableA or TSQLMyTableB. All this worked perfectly until your last commit (1.18.1991), now it rises exception: 'TSQLModel must include TSQLMyTable' in GetTableIndexSafe
Last edited by zed (2015-10-14 17:07:14)
Offline
I guess you have a published field pointing to an abstract TSQLMyTable...
Now we are ensuring the pointed table is available when using external references.
It is needed for proper cascading during deletion operations...
Could you tell us more about the TSQLMyTable* relationship?
Online
...
TSQLMark = class(TSQLRecord)
public
FCategory: TSQLCategory;
FImage: TSQLMarkImage;
FAppearance: TSQLMarkAppearance;
FName: RawUTF8;
FDesc: RawUTF8;
FGeoType: TSQLGeoType;
FGeoCount: Cardinal;
FGeoLonSize: Cardinal;
FGeoLatSize: Cardinal;
FGeoWKB: TSQLRawBlob;
published
property mCategory: TSQLCategory read FCategory write FCategory;
property mImage: TSQLMarkImage read FImage write FImage;
property mAppearance: TSQLMarkAppearance read FAppearance write FAppearance;
property mName: RawUTF8 read FName write FName;
property mDesc: RawUTF8 read FDesc write FDesc;
property mGeoType: TSQLGeoType read FGeoType write FGeoType;
property mGeoCount: Cardinal read FGeoCount write FGeoCount;
property mGeoLonSize: Cardinal read FGeoLonSize write FGeoLonSize;
property mGeoLatSize: Cardinal read FGeoLatSize write FGeoLatSize;
property mGeoWKB: TSQLRawBlob read FGeoWKB write FGeoWKB;
end;
TSQLMarkClass = class of TSQLMark;
TSQLMarkDBMS = class(TSQLMark)
public
FLeft, FRight, FBottom, FTop: Cardinal;
published
property mLeft: Cardinal read FLeft write FLeft;
property mRight: Cardinal read FRight write FRight;
property mBottom: Cardinal read FBottom write FBottom;
property mTop: Cardinal read FTop write FTop;
end;
TSQLMarkMongoDB = class(TSQLMark)
public
FGeoJsonIdx: Variant;
published
property mGeoJsonIdx: Variant read FGeoJsonIdx write FGeoJsonIdx;
end;
TSQLMarkView = class(TSQLRecord)
public
FUser: TSQLUser;
FMark: TSQLMark;
FCategory: TSQLCategory;
FVisible: Boolean;
published
property mvUser: TSQLUser read FUser write FUser;
property mvMark: TSQLMark read FMark write FMark;
property mvCategory: TSQLCategory read FCategory write FCategory;
property mvVisible: Boolean read FVisible write FVisible;
end;
...
And yes, in my TSQLMarkView I have field that pointing to TSQLMark. What can I do in this case? Change field type declaration in TSQLMarkView form TSQLMark to TID?
Offline
I have the same message cause we derive a class from TSQLAuthUser and TSQLAuthGroup.
What can we do here ? (atm we rewinded to 1.18.1989)
AB you're right, we never will have a table of this class and use this for a long time now.
Cascading delete we also do not need !
Last edited by itSDS (2015-10-15 09:14:23)
Rad Studio 12.1 Santorini
Offline
TDFSQLAuthUser = class(TSQLAuthUser)
public
class procedure InitializeTable(Server: TSQLRestServer; const FieldName: RawUTF8; Options: TSQLInitializeTableOptions); override;
end;
TDFSQLAuthGroup = class(TSQLAuthGroup)
public
class procedure InitializeTable(Server: TSQLRestServer; const FieldName: RawUTF8; Options: TSQLInitializeTableOptions); override;
end;
Rad Studio 12.1 Santorini
Offline
As you stated above you have to rewrite TSQLAuthUser that tGroup is form Type TID now.
I think that is not what you wanted - or ?
Rad Studio 12.1 Santorini
Offline
Why does it affect TSQLAuthUser?
Those tables are a special case.
You could still use in this case a true class, since the mORMot.pas creates its own instances with the registered user/group classes.
Online
the only thing i did to TSQLAuthUser/Group was to derive it an add Initialize Proc.
Now we get the error that TSQLAuthGroup is not registered cause TSQLAuthUser references to it.
In Former Version this was no Problem !
Now my Question what can we do.
I think there is a conceptual error if i can not refer to derived classes.
Rad Studio 12.1 Santorini
Offline
Please try http://synopse.info/fossil/info/5293458f2b
I made some modifications to the code so that it allows lazy initialization of the table class.
But of course, cascaded deletion of the foreign keys properties would work only if the published field class is an exact match.
Online
tyvm, i actually did not dig into the deep. But we don't use cascading deletes. We delete the depending records by hand ...
Rad Studio 12.1 Santorini
Offline
I don't use cascading deletes too and with your last fixes my code works fine, again
Offline