#1 2021-01-23 16:15:09

Vitaly
Member
From: UAE
Registered: 2017-01-31
Posts: 168
Website

mORMot2 TRestServerDB for external DB

In 1.18 I use TSQLRestServerDB-based class and model with optional different "external" TSQLDBConnectionProperties (particularly TSQLDBSQLite3ConnectionProperties, TSQLDBZEOSConnectionProperties, TSQLDBFireDACConnectionProperties). There (for some DBMS) I can access TRestStorageExternal(StaticVirtualTable[]).OnEngineAddComputeID and override EngineAdd, EngineUpdate, EngineBatchSend and so on. But I can't do the same with TRestServerDB in 2.0 sad

I'm a bit confused, probably I got it totally wrong. Will appreciate any clarification.

Last edited by Vitaly (2021-01-23 16:19:54)

Offline

#2 2021-01-23 18:55:21

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: mORMot2 TRestServerDB for external DB

You still can access TRestStorageExternal when you register the external tables in mORMot 2.

Offline

#3 2021-01-24 08:46:08

Vitaly
Member
From: UAE
Registered: 2017-01-31
Posts: 168
Website

Re: mORMot2 TRestServerDB for external DB

Ok, probably this decision is ugly, but at least it works for my case.

Instead of (1.18)

              TSQLRestStorageExternal(StaticVirtualTable[LModel.Tables[i]]).OnEngineAddComputeID :=
                DoOnEngineAddComputeIDFirebird;

for 2.0 I used

          TRestStorageExternal(TRestOrmServer(server).StaticVirtualTable[LModel.Tables[i]]).OnEngineAddComputeID :=
            DoOnEngineAddComputeIDFirebird;

Overriding EngineAdd, EngineUpdate, EngineBatchSend for the whole TRestServerDB-based class, unfortunately, seems to be impossible, so far at least.

Offline

#4 2021-01-24 08:57:20

Vitaly
Member
From: UAE
Registered: 2017-01-31
Posts: 168
Website

Re: mORMot2 TRestServerDB for external DB

btw, if somebody is interested in my current results for external DBs:

TSQLDBSQLite3ConnectionProperties - fine

TSQLDBFireDACConnectionProperties (FB 2.5.9) - fine

TSQLDBZEOSConnectionProperties (FB 2.5.9, ZeosLib git master f347957defc8e89c381f5d06596ac3a170c5994e 2021-01-21):
   with USE_SYNCOMMONS - nothing compiles since 1.18 units namings in Zeos;
   without USE_SYNCOMMONS - compiles but throws errors during connection, like

Error SQLITE_ERROR (1) [Step] using 3.34.0 - TSqlDBZEOSConnectionProperties: unexpected TZSQLType "stUnknown", extended_errcode=1

Offline

#5 2021-01-24 13:57:07

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: mORMot2 TRestServerDB for external DB

@Vitaly
I didn't make any test with Zeos.
For sure, USE_SYNCOMMONS won't work since it is mORMot 1.18 specific.
Next week, I will try to debug it. Perhaps even mORmot 1.18 didn't work when USE_SYNCOMMONS was not defined. wink

Offline

#6 2021-01-24 15:49:54

Vitaly
Member
From: UAE
Registered: 2017-01-31
Posts: 168
Website

Re: mORMot2 TRestServerDB for external DB

ab wrote:

Perhaps even mORmot 1.18 didn't work when USE_SYNCOMMONS was not defined. wink

I liked your supposition, so I rollbacked the actual "migration" project to 1.18 use and tested it with the same Zeos and without USE_SYNCOMMONS. It works fine, it is hard to say how fast/slow in comparing, but it works.

I can continue migration/testing with FireDAC without any problem, so Zeos support easily can wait if you'll have more important things (I might already distract you enough with my current 2.0 feedback).

Offline

#7 2021-01-28 07:47:54

Vitaly
Member
From: UAE
Registered: 2017-01-31
Posts: 168
Website

Re: mORMot2 TRestServerDB for external DB

Just a small non-critical issue, but very strange.
Creating a TRestServerDB instance with an empty model causes AV:

TRestServerDB.CreateWithOwnModel([]);

I hardly can imagine that someday I'll need an empty model, but I guess it'll be better to handle it without AV exception.

Anyway, I tried to debug and got a bit strange result. AV appears in

constructor TRestOrmServer.Create(aRest: TRest);
  ... 
  SetLength(fTrackChangesHistoryTableIndex, fTrackChangesHistoryTableIndexCount);
  for t := 0 to fTrackChangesHistoryTableIndexCount - 1 do
    fTrackChangesHistoryTableIndex[t] := -1;                                <---- hear
  ...

where (as I assume) it shouldn't get at all because of fTrackChangesHistoryTableIndexCount = 0. I guess I'm missing something simple...

Offline

#8 2021-02-27 10:34:24

EgonHugeist
Member
From: Germany
Registered: 2013-02-15
Posts: 190

Re: mORMot2 TRestServerDB for external DB

@Vitaly,
got 8.0 running with mORMot 2. See https://sourceforge.net/p/zeoslib/code-0/7347/ also on Linux 64Bit.

Note the "USE_SYNCOMMONS" define is left for 1.18. To be able to distinguish between the unit names i use a new define "MORMOT2" yet. We can change the name if somebody has objections..?
Regards, Michael

Last edited by EgonHugeist (2021-02-27 18:03:01)

Offline

#9 2021-02-27 14:11:42

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: mORMot2 TRestServerDB for external DB

Thanks @Michael again for mORMot 2 support!

A lot of small changes indeed!
smile

Offline

#10 2021-02-27 18:07:03

EgonHugeist
Member
From: Germany
Registered: 2013-02-15
Posts: 190

Re: mORMot2 TRestServerDB for external DB

Not a problem. OpenSource rocks!
Leave some work 4u: Mormot v2 should not use the USE_SYNCOMMONS define any more. Replace it with MORMOT2. If you or others think the define is "dangerous" to use give me a hint for a better name and i'll replace it ASAP.
Michael

Offline

#11 2021-02-28 16:34:09

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: mORMot2 TRestServerDB for external DB

MORMOT2 seems fine to be, since it is internal to Zeos.inc / ZDBC.
It should not hurt.

See https://github.com/synopse/mORMot2/comm … 0af2cacc39

Offline

#12 2021-02-28 19:54:10

Vitaly
Member
From: UAE
Registered: 2017-01-31
Posts: 168
Website

Re: mORMot2 TRestServerDB for external DB

Checked a couple of projects with mORMot2 and Zeos/FB. Seems, all ORM and Batch operations are going well. Thanks! smile

Delphi 10.4.2, Win64, freshest mORMot2, Zeos r7349, FB 2.5.9
PUREMORMOT2;MORMOT2

Offline

Board footer

Powered by FluxBB