Diferent behavior by TFields descendants

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
maurofalcao
Posts: 2
Joined: Fri 29 Jan 2021 11:30

Diferent behavior by TFields descendants

Post by maurofalcao » Fri 29 Jan 2021 13:15

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.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Diferent behavior by TFields descendants

Post by MaximG » Mon 01 Feb 2021 21:54

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

maurofalcao
Posts: 2
Joined: Fri 29 Jan 2021 11:30

Re: Diferent behavior by TFields descendants

Post by maurofalcao » Mon 01 Feb 2021 22:31

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?

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Diferent behavior by TFields descendants

Post by MaximG » Thu 04 Feb 2021 15:40

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

mauro_falcao
Posts: 2
Joined: Thu 26 Apr 2012 12:17
Location: Brazil

Re: Diferent behavior by TFields descendants

Post by mauro_falcao » Mon 31 May 2021 17:54

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!

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Diferent behavior by TFields descendants

Post by MaximG » Fri 18 Jun 2021 11:49

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.

Post Reply