Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-04

Error in my mind or typo in sqldbtoolsunit.pas?

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Reinier Olislagers

Hi list,

I'm working on improving bufdataset testing in the dbtestframework, documenting the framework a bit more. (Attached FYI my current version of the readme; comments welcome as always).

I found this in sqldbtoolsunit.pas:
destructor TSQLDBConnector.Destroy;
...
  if assigned(FTransaction) then
    begin
    try
      if Ftransaction.Active then Ftransaction.Rollback;
      Ftransaction.StartTransaction;
      Fconnection.ExecuteDirect('DROP TABLE FPDEV2');
      Ftransaction.Commit;
    Except
      if Ftransaction.Active then Ftransaction.Rollback
    end; // try
    end;

... however, I don't see any corresponding CREATE TABLE FPDEV2 in the rest of the code or any mention of it?

In the rest of the code, it seems the tables FPDEV and FPDEV_FIELDS are correctly
CREATEd in CreateNDatasets/CreateFieldDataset
and
DROPped in DropNDatasets/DropFieldDataset

That FPDEV2 code seems like some last-ditch recovery effort to delete
the generated tables... couldn't that be replaced by:
destructor TSQLDBConnector.Destroy;
...
  if assigned(FTransaction) then
    begin
    try
      if Ftransaction.Active then Ftransaction.Rollback;
      Ftransaction.StartTransaction;
      Fconnection.ExecuteDirect('DROP TABLE FPDEV');
      Ftransaction.Commit;
      Ftransaction.StartTransaction;
      Fconnection.ExecuteDirect('DROP TABLE FPDEV_FIELDS');
      Ftransaction.Commit;
    Except
      if Ftransaction.Active then Ftransaction.Rollback
    end; // try
    end;

Thanks,
Reinier

Ludo Brands
to Reinier Olislagers
... however, I don't see any corresponding CREATE TABLE FPDEV2 in the rest of the code or any mention of it?

In the TestFieldTypes unit there are several 'create table FPDEV2' whenever a special particular table is needed. Nowhere FPDEV2 is dropped. So I assume the unwritten convention is that FPDEV2 is dropped by SQLDBToolsUnit in TSQLDBConnector.Destroy. To be confirmed.

Ludo