From 1443a6ce99c5eceef332707080c980903fb1fc70 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Fri, 19 Jul 2024 11:16:58 +0200 Subject: [PATCH] Issue #1984: fix undefined and wrong result of TMySQLQuery.TableName when using a table alias --- source/dbconnection.pas | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 68c8bd16..096bb754 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -9944,15 +9944,10 @@ var Obj: TDBObject; begin Field := FConnection.Lib.mysql_fetch_field_direct(FCurrentResults, Column); - {Connection.Log(lcDebug, FColumnNames[Column]+':'+ - ' org_table:'+Field.org_table+ - ' table:'+Field.table+ - ' table^=org_table^:'+(Field.table^ = Field.org_table^).ToInteger.ToString+ - ' table=org_table:'+(Field.table = Field.org_table).ToInteger.ToString - );} FieldDb := FConnection.DecodeAPIString(Field.db); FieldTable := FConnection.DecodeAPIString(Field.table); FieldOrgTable := FConnection.DecodeAPIString(Field.org_table); + // Connection.Log(lcInfo, FColumnNames[Column]+': org_table:'+FieldOrgTable+' table:'+FieldTable); if FieldTable <> FieldOrgTable then begin // Probably a VIEW, in which case we rely on the first column's table name. @@ -9966,7 +9961,9 @@ begin end; end; end; - end else begin + end; + + if Result.IsEmpty then begin // Normal table column // Note: this is empty on data tab TEXT columns with LEFT(..) clause Result := FieldOrgTable;