You are not logged in.
Pages: 1
Patch contains:
-OnEngineLockedNextID callback event (for example SQL select with some sequence function, or some other stuff depending on the DB back-end)
-EngineIgnoreID for speed up "insert into" for external databases (safer method in many cases than default "select max(id)") Without EngineIgnoreID, I have a lot of errors (duplicated id) in my n-tier system with many non-mormot-clients.
Fell free to modify TOnEngineLockedNextID event parameters (this is only proposition).
Example:
type
TCustomVirtualTableExternal = class(TSQLVirtualTableExternal)
public
constructor Create(aModule: TSQLVirtualTableModule; const aTableName: RawUTF8;
FieldCount: integer; Fields: PPUTF8CharArray); override;
end;
var
aRestServer: TSQLMyServer;
constructor TCustomVirtualTableExternal.Create(aModule: TSQLVirtualTableModule;
const aTableName: RawUTF8; FieldCount: integer; Fields: PPUTF8CharArray);
begin
inherited;
if fStatic.InheritsFrom(TSQLRestStorageExternal) then
begin
// ID generated for example by trigger
//TSQLRestStorageExternal(fStatic).OnEngineLockedNextID := aRestServer.OnEngineLockedNextID;
// or auto generated ID by DB (for speed up batch and normal record add)
TSQLRestStorageExternal(fStatic).EngineIgnoreID := true;
end;
end;
{...}
begin
{...}
VirtualTableExternalRegisterAll(aModel, aProps, TCustomVirtualTableExternal);
{...}
end.
Patch available at:
https://drive.google.com/file/d/0B4PZhd … sp=sharing
This is patch for:
http://synopse.info/fossil/tktview/2013 … 22418760d5
best regards,
Maciej Izak
Last edited by hnb (2015-09-02 07:05:38)
best regards,
Maciej Izak
Offline
I've committed http://synopse.info/fossil/info/334a9933e8
The properties have a diverse names, but implement the same idea.
I did not include the TSQLVirtualTableExternal sub-classing part of the patch.
IMHO this is not how you should do it.
Just use TSQLRestStorageExternal.Instance() method to retrieve directly the TSQLRestStorageExternal instance, and set the properties as expected, after VirtualTableExternalRegister*() call.
Online
I Arnaud,
I haven't been updated my mORMot source for a while, I see the newly added OnEngineAddComputeID event for TSQLRestStorageExternal - looks like it's for **external** DB only. Is there already a similar event for customizing the record ID value for new records on the server side?
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
I've committed http://synopse.info/fossil/info/334a9933e8
The properties have a diverse names, but implement the same idea.
Thanks for that! "select max" was very buggy solution for many clients. You are right about TSQLVirtualTableExternal thanks!
best regards,
Maciej Izak
Offline
Pages: 1