#1 2016-06-30 09:43:47

hnb
Member
Registered: 2015-06-15
Posts: 290

[Patch] Custom RTTI PropInfo for custom types

Hi!

I have idea for custom RTTI PropInfo for custom types. Patch attached:

(moved below)

Example usage:

type
  TDouble_Precision2 = type Double;

  TSQLPropInfoRTTIDouble_Precision2 = class(TSQLPropInfoRTTIDouble)
  public
    procedure GetValueVar(Instance: TObject; ToSQL: boolean;
      var result: RawUTF8; wasSQLString: PBoolean); override;
  end;

implementation

procedure TSQLPropInfoRTTIDouble_Precision2.GetValueVar(Instance: TObject; ToSQL: boolean;
  var result: RawUTF8; wasSQLString: PBoolean);
var
  D: Double;
begin
  if wasSQLString<>nil then
    wasSQLString^ := false;
  Result := FormatFloat('0.00', PropInfo.GetExtendedValue(Instance));
end;

begin
  RegisterSQLPropInfo(TypeInfo(TDouble_Precision2), TSQLPropInfoRTTIDouble_Precision2);
end.

Last edited by hnb (2016-07-06 06:17:23)


best regards,
Maciej Izak

Offline

#2 2016-07-06 06:19:39

hnb
Member
Registered: 2015-06-15
Posts: 290

Re: [Patch] Custom RTTI PropInfo for custom types

Ping. Attached patch has no performance issue for existing code base... That feature has critical meaning for my projects.

Corrected patch: https://drive.google.com/file/d/0B4PZhd … sp=sharing


best regards,
Maciej Izak

Offline

#3 2016-07-11 07:07:44

hnb
Member
Registered: 2015-06-15
Posts: 290

Re: [Patch] Custom RTTI PropInfo for custom types

Any feedback ? tongue Can I commit my changes to fossil?


best regards,
Maciej Izak

Offline

#4 2016-07-11 12:48:36

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

Re: [Patch] Custom RTTI PropInfo for custom types

Please do it.

Online

#5 2016-07-12 16:42:55

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

Re: [Patch] Custom RTTI PropInfo for custom types

I've updated the implementation, to use a class procedure TSQLPropInfoRTTI.RegisterTypeInfo() for ORM custom types.
Makes more sense to me than a global function.
See http://synopse.info/fossil/info/76b39f90090f5

Online

#6 2016-07-13 11:04:10

hnb
Member
Registered: 2015-06-15
Posts: 290

Re: [Patch] Custom RTTI PropInfo for custom types

Looks much better -,-


best regards,
Maciej Izak

Offline

#7 2016-07-13 16:22:54

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

Re: [Patch] Custom RTTI PropInfo for custom types

But it is just some new looking appearance.
Idea is from you and your patch!
smile

Online

Board footer

Powered by FluxBB