TableAlias not correct

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
tonisanta
Posts: 55
Joined: Wed 04 Apr 2007 17:25

TableAlias not correct

Post by tonisanta » Wed 12 Oct 2016 08:06

Hi,
I've the following SQL

Code: Select all

select top 100 l1.id, l1.id_first_titolare ,
 l2.id, l2.id_first_Titolare
from link l1 inner join link l2 on l1.id = l2.id_first_titolare
order by l1.id
so the same table is invoked two times.
When I try to get the fieldnames with tablealiases always "l1" is returned and never "l2".

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  i: integer;
  FieldDesc: TCRFieldDesc;
  Field: TField;
  TblName: string;
begin
  msquery1.active := true;
  for i := 0 to msQuery1.Fields.Count - 1 do
  begin
    Field := msquery1.Fields[i];
    if Field.FieldKind <> fkData then
      continue;
    FieldDesc := TCRFieldDesc(msQuery1.GetFieldDesc(Field));
    TblName := FieldDesc.TableInfo.TableAlias;
    memo1.lines.add(TblName + '.' + FieldDesc.ActualName);
  end;

end;
Seems the TCRFieldDesc doesn't contain the correct Alias when same tables is included multiple times.
best regards
Toni Santa

azyk
Devart Team
Posts: 1057
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: TableAlias not correct

Post by azyk » Mon 14 Nov 2016 14:41

Thank you for the information. We have reproduced the problem and will investigate it.

azyk
Devart Team
Posts: 1057
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: TableAlias not correct

Post by azyk » Fri 20 Jan 2017 15:30

We have fixed this problem. This fix will be included in the next SDAC build.

Post Reply