Issue #1984: fix undefined and wrong result of TMySQLQuery.TableName when using a table alias

This commit is contained in:
Ansgar Becker
2024-07-19 11:16:58 +02:00
parent 4c251ec2b6
commit 1443a6ce99

View File

@ -9944,15 +9944,10 @@ var
Obj: TDBObject; Obj: TDBObject;
begin begin
Field := FConnection.Lib.mysql_fetch_field_direct(FCurrentResults, Column); 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); FieldDb := FConnection.DecodeAPIString(Field.db);
FieldTable := FConnection.DecodeAPIString(Field.table); FieldTable := FConnection.DecodeAPIString(Field.table);
FieldOrgTable := FConnection.DecodeAPIString(Field.org_table); FieldOrgTable := FConnection.DecodeAPIString(Field.org_table);
// Connection.Log(lcInfo, FColumnNames[Column]+': org_table:'+FieldOrgTable+' table:'+FieldTable);
if FieldTable <> FieldOrgTable then begin if FieldTable <> FieldOrgTable then begin
// Probably a VIEW, in which case we rely on the first column's table name. // Probably a VIEW, in which case we rely on the first column's table name.
@ -9966,7 +9961,9 @@ begin
end; end;
end; end;
end; end;
end else begin end;
if Result.IsEmpty then begin
// Normal table column // Normal table column
// Note: this is empty on data tab TEXT columns with LEFT(..) clause // Note: this is empty on data tab TEXT columns with LEFT(..) clause
Result := FieldOrgTable; Result := FieldOrgTable;