#1 2021-11-20 10:50:12

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Mormot2, example extdb-bench, TTestDatabaseExternalAbstract problem

I tried to compile and run the extdb-bench example.
I created a Mysql test as follows:

   TTestmysql = class(TTestDatabaseExternalAbstract)
  private
  published
    procedure _SynDBmysql;
  end;

procedure TTestmysql._SynDBmysql;              var a:TSqlDBFireDACConnectionProperties;
begin
  a:=TSqlDBFireDACConnectionProperties.Create('MySQL?Server=localhost;Port=3306','db','user','pass');
  a.Parameters.Add('CharacterSet=utf8');
  RunExternal(a);
end;

I noticed that the test always fails (Using Delphi 11 and MariaDB 10.6.5).
The problem is caused by the following code:

procedure TTestDatabaseExternalAbstract.ClientCreate;
var
  lTables: TRawUtf8DynArray;
begin
  if (Props <> nil) and (dbDropTable in Flags) then
  begin
    // drop only if table exist
    Props.GetTableNames(lTables);
    if FindPropName(lTables, 'SAMPLERECORD') >= 0 then
    begin
      Props.ClearConnectionPool;
      Props.ThreadSafeConnection.Disconnect;
      Props.ExecuteNoResult('drop table SAMPLERECORD', []);
    end;
  end;
  inherited ClientCreate;
end;

Inside lTables, the table names are in the form dbname.tablename and it should be changed to the following:
    if FindPropName(lTables, <dbname>+'.'+'SAMPLERECORD') >= 0 then

As a newbie in mormot, I am not sure if mysql config needs something more for ITables to not include the dbname or something else.
Where is the error?

By the way:
The same happens with Postgres that it is included in the example:
  mormot.db.sql.postgres, is missing in uses clause
and a "public." is needed before in the same statement:

    if FindPropName(lTables, <dbname>+'.'+'SAMPLERECORD') >= 0 then

Even with that direct access postgres fails

Just FYI. Thanks again.

Last edited by dcoun (2021-11-20 12:24:49)

Offline

#2 2022-01-06 13:31:30

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

Re: Mormot2, example extdb-bench, TTestDatabaseExternalAbstract problem

I have just fixed this sample, and tested it with PostgreSQL.
Please check https://github.com/synopse/mORMot2/commit/779ad860

Seems to work fine by now.

Offline

#3 2022-01-06 15:50:31

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Re: Mormot2, example extdb-bench, TTestDatabaseExternalAbstract problem

ab wrote:

I have just fixed this sample, and tested it with PostgreSQL.
Please check https://github.com/synopse/mORMot2/commit/779ad860

Seems to work fine by now.

Thank you @ab

Offline

Board footer

Powered by FluxBB