Bug with *TCRFieldDesc.TableInfo.TableName* (worked in Version 5)

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
dschuch
Posts: 73
Joined: Thu 05 Feb 2009 15:29
Location: Dresden

Bug with *TCRFieldDesc.TableInfo.TableName* (worked in Version 5)

Post by dschuch » Sun 19 Jan 2020 14:21

There is a new bug in TCRFieldDesc(FieldDesc).TableInfo.TableName since Version 6. In Versions 5.3.9 and earlier this worked fine.

I create 2 Tables and JOIN them.
TCRFieldDesc(FieldDesc).TableInfo.TableName will hold the wrong table.

Try this view lines of code and you will see it.

Create tables - Statement:

Code: Select all

DROP TABLE IF EXISTS first;
CREATE
-- TEMP
TABLE first
(
  id SERIAL,
  context character varying(32)
);

DROP TABLE IF EXISTS second;
CREATE
-- TEMP
TABLE second
(
  id integer,
  second_first_id integer,
  context character varying(32)
);

-- Query to select Data

SELECT
 first.context AS first_ctx,
 second.context AS second_ctx,
 *
FROM
 first LEFT JOIN second ON first.id = second_first_id

Code: Select all

 var Q1 : TPgQuery;
 ...
 for I := 0 to Q1.FieldCount - 1 do begin
     FieldDesc := TCustomDADataSet(Q1).GetFieldDesc(Q1.Fields[I]);
     MemoSQLLog.Lines.Add(Q1.Fields[I].FieldName + ' -> ' + TCRFieldDesc(FieldDesc).TableInfo.TableName)
 end;
if you execute this - this error occurs:

Code: Select all

first_ctx -> first
second_ctx -> first   !!!!!!!!!!!!!!!!!!!!! WRONG !!!!!!!!!!!!!!!!!!!!!!!
id -> first
context -> first
id_1 -> second
second_first_id -> second
context_1 -> second
BTW:
if you execute this with temp tables everything is fine:
commt in the --TEMP blocks

Code: Select all

-- CREATE TABLES as TEMP tables (use Script above)
SELECT
 first.context AS first_ctx,
 second.context AS second_ctx
FROM
 first LEFT JOIN second ON first.id = second_first_id
 ========================== 
first_ctx -> first
second_ctx -> second

MaximG
Devart Team
Posts: 1419
Joined: Mon 06 Jul 2015 11:34

Re: Bug with *TCRFieldDesc.TableInfo.TableName* (worked in Version 5)

Post by MaximG » Fri 24 Jan 2020 10:28

Thank you for the information. We have reproduced the issue and will investigate its origin. As a temporary solution, you can use protocol version 3.0 to work with PostgreSQL :

Code: Select all

PgConnection.ProtocolVersion := pv30;

Post Reply