#1 2019-08-01 14:25:42

Joe
Member
Registered: 2014-10-13
Posts: 12

SynDB.TSQLDBStatementWithParamsAndColumns.ColumnIndex() broken

Hello,
today I have discovered that commit https://synopse.info/fossil/info/888baa599a51ab0a broke functionality of SynDB.TSQLDBStatementWithParamsAndColumns.ColumnIndex() method - it never finds a column, because it compares TSQLDBColumnProperty records by pointers.

Regards,
Joe

Offline

#2 2019-08-01 14:42:13

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

Re: SynDB.TSQLDBStatementWithParamsAndColumns.ColumnIndex() broken

With which compiler?

Online

#3 2019-08-01 15:16:26

Joe
Member
Registered: 2014-10-13
Posts: 12

Re: SynDB.TSQLDBStatementWithParamsAndColumns.ColumnIndex() broken

ab wrote:

With which compiler?

Found with Delphi 10.3.1

Offline

#4 2019-08-27 11:17:59

Joe
Member
Registered: 2014-10-13
Posts: 12

Re: SynDB.TSQLDBStatementWithParamsAndColumns.ColumnIndex() broken

Ok, I have analyzed it a bit more. The problem is that extended RTTI used in the TDynArray.ToKnownType() method it returns djCustom and thus the comparison fails to dig deeper (to compare first string elem of record). I have patched it this way:

  {$ifdef ISDELPHI2010} // seems inconsistent with FPC - only for Delphi 2010+
-  if (result=djNone) and (fElemType2<>nil) then // try from extended RTTI
+  if (result=djNone) and (fElemType2<>nil) and not (PTypeKind(fElemType2)^ in [tkClass, tkInterface, tkRecord, tkArray, tkDynArray]) then begin // try from extended RTTI
    result := RTTI[TJSONCustomParserRTTI.TypeInfoToSimpleRTTIType(fElemType2)];
+    if result = djCustom then  // unknown types
+      Result:= djNone;
  end;
  {$endif}

Offline

#5 2019-08-28 09:51:11

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

Re: SynDB.TSQLDBStatementWithParamsAndColumns.ColumnIndex() broken

This is weird because TypeInfoToSimpleRTTIType() returns indeed ptCustom, but RTTI[ptCustom] returns djNone in my computer (with Delphi 10.3).
So result should never be djCustom anyway.

I have made a deeper refactoring to avoid issues as you discovered.
Please check https://synopse.info/fossil/info/51eced20b8

Online

#6 2019-08-28 14:55:48

Joe
Member
Registered: 2014-10-13
Posts: 12

Re: SynDB.TSQLDBStatementWithParamsAndColumns.ColumnIndex() broken

ab wrote:

I have made a deeper refactoring to avoid issues as you discovered.
Please check https://synopse.info/fossil/info/51eced20b8

It is working perfectly now (I have removed that dirty patch of mine). Thanks.

Offline

Board footer

Powered by FluxBB