Delphi: Warnigs → Errors

Want to force your dev team to address Compiler Warnings rather than ignoring them?

Elevate Warnings to Errors:

1) Go to Project Options
2) Under Delphi Compiler, select Hints and Warnings
3) Expand the Output warnings item
4) For each important Warning you wish for your developers to address rather than ignore, select the drop-down list and select Error.

Enjoy!

Thanks Simon Stuart for hint!

Delphi+Elevate+Warnings+to+Errors

Advertisements

Mixing datasets

One user asked me:

I have master-detail application using PostgresDAC. But I want to set for each TPSQLDataset descendant it’s own TPSQLDatabase. Is it possible?

The answer was:

Have no idea why do you need this, but we’ve checked this functionality and we are confirming that this can be done.

Why am I writing about this? Because curiosity is in the blood. 🙂 My next step was to mix TMySQLDataset descendant from MySQLDAC as master and PostgresDAC’s object as slave. Holy molly! It works. Then I tried another TDataset descendants from BDE, ADO, FIBPlus etc.

They can be mixed any way you want. Yeah, baby! True perversion. 🙂

How to get rid of published property in Delphi

note This article available in Russian.

Preface

Developing PostgresDAC I faced such problem twice. And both times changes affected TPSQLDump component as most developing class.

Mission

Change TPSQLDump.TableName: string property to TPSQLDump.TableNames: TStrings.

Solution

Code speaks for itself:

    TPSQLDump = class(TComponent)
      private
      ...
        procedure ReadTableName(Reader: TReader);
      protected
        procedure DefineProperties(Filer: TFiler); override;
      ...
      published
      ...
        //property TableName: string ...
        property TableNames: TStrings read FTableNames
                                   write SetTableNames;
      ...
    end; //TPSQLDump

implementation

...

procedure TPSQLDump.DefineProperties(Filer: TFiler);
begin
  inherited;
  Filer.DefineProperty('TableName', ReadTableName, nil, False);
end;

procedure TPSQLDump.ReadTableName(Reader: TReader);
var S: string;
begin
  S := Reader.ReadString;
  if S > '' then FTableNames.Append(S);
end;

Explanation

We defined TableName property as if it still exists and assigned ReadTableName function to read its value. Since we didn’t assigned a function for writing (we pass nil as second parameter) this property will never be stored in the future. Problem solved.

PS

Thanks to Alexey Vukolov aka vuk for the idea.