Page 1 of 1

Diferent behavior by TFields descendants

Posted: Fri 29 Jan 2021 13:15
by maurofalcao
Hi,

I coded one descendant class of TStringField where I modify the GetAsAnsiString method to result in anonymized data.
But my code is used only when I declare persistent fields in Fields Editor of TOraQuery. If I did not declare these persistent fields, my implementation isn't called.

I need that the behavior is the same, independent of TOraQuery having persistent fields or not.
Could someone help me, please?

See above my modified class:

Code: Select all

unit AnonymousFields;

interface

uses  DB, Sysutils, Classes;

type

  TStringField = class(DB.TStringField)
  public
    //function GetValue(var Value: AnsiString): Boolean;
    function GetAsAnsiString: AnsiString; override;
  end;

  TWideStringField = class(TStringField)
  public
    //function GetValue(var Value: AnsiString): Boolean;
    function GetAsString: string; override;
    function GetAsAnsiString: AnsiString; override;
    function GetAsWideString: UnicodeString; override;
  end;

  TDateTimeField = class(DB.TDateTimeField)
  public
    function GetAsString: string; override;
    function GetAsDateTime: TDateTime; override;
    procedure GetText(var Text: string; DisplayText: Boolean); override;
  end;

implementation



{ TStringField }

function TStringField.GetAsAnsiString: AnsiString;
begin
  inherited;
  Result := '$$$$$$$$$$';
end;

{ TWideStringField }

function TWideStringField.GetAsAnsiString: AnsiString;
begin
  inherited;
  Result := '##########';
end;

function TWideStringField.GetAsString: string;
begin
  inherited;
  Result := '##########';
end;

function TWideStringField.GetAsWideString: UnicodeString;
begin
  inherited;
  Result := '##########';
end;

{ TDateTimeField }

function TDateTimeField.GetAsDateTime: TDateTime;
begin
  inherited;
  Result := 0;
end;

function TDateTimeField.GetAsString: string;
begin
  inherited;
  Result := '**********';
end;

procedure TDateTimeField.GetText(var Text: string; DisplayText: Boolean);
begin
  inherited;
  text := '**/**/****';
end;

end.

Re: Diferent behavior by TFields descendants

Posted: Mon 01 Feb 2021 21:54
by MaximG
The issue you describe does not relate to the work of our product. To find a required solution, please refer to the Embarcadero documentation or one of the specialized forums

Re: Diferent behavior by TFields descendants

Posted: Mon 01 Feb 2021 22:31
by maurofalcao
Hi,

I agree with you in part, because my issue occurs when I use TOraQuery, If you give me a chance to show you what happens, maybe you understand my problem.
Can I send you a "poc" that exemplify the scenario?

Re: Diferent behavior by TFields descendants

Posted: Thu 04 Feb 2021 15:40
by MaximG
Your example inherits TStringField, TDateTimeField, and other classes (and the descendant classes are given the same names as their parent classes), however, it doesn't use the TOraQuery class, which inherits TDataSet. Please send the code that uses TOraQuery via the e-suppot form: https://www.devart.com/company/contactform.html

Re: Diferent behavior by TFields descendants

Posted: Mon 31 May 2021 17:54
by mauro_falcao
Hello, @MaximG.

I sent, as you oriented, an e-mail to support by Contact Form. The subject is the same to this caption post. Attached to this e-mail, I sent a POC that demonstrates the case.
I hope you may help me!

Re: Diferent behavior by TFields descendants

Posted: Fri 18 Jun 2021 11:49
by MaximG
Sorry for the late reply. To implement a full-functional descendant class, you need ODAC Professioal Edition with source code. This edition will allow you to implement the desired behavior.