antares icon indicating copy to clipboard operation
antares copied to clipboard

Columns missing in the result if they have same names

Open relationaldba opened this issue 2 years ago • 8 comments

Describe the bug When the result set has two or more columns that have the same name and datatype, Antares hides duplicate columns. This can be seen in the attached screenshot.

To Reproduce Steps to reproduce the behavior:

  1. Connect to PostgreSQL database Antares SQL client
  2. Run the below query (this can be replicated by any query that selects the columns twice)
SELECT 
    class_table.relname,
    class_table.relkind,
    class_depend.relname,
    class_depend.relkind
FROM pg_depend 
    INNER JOIN pg_class AS class_depend
        ON class_depend.oid = pg_depend.objid 
    INNER JOIN pg_class AS class_table
        ON class_table.oid = pg_depend.refobjid;
  1. See the results have missing columns

Expected behavior Results should show all columns, even if they are duplicates.

Screenshots

image

Application (please complete the following information):

  • App client PostgreSQL
  • App version 0.7.12
  • Installation source: Linux DEB

Environment (please complete the following information):

  • OS name: Ubuntu
  • OS version 23.04
  • DB name PostgreSQL
  • DB version 11, 15 (I did not test on PostgreSQL v12, v13 and v14, but I suspect they are impacted too)

Additional context NA

relationaldba avatar Jul 24 '23 16:07 relationaldba

Its something that happens with join queries on pg_catalog. Sadly from PostgreSQL driver i receive in metadata the same table ID for all fields and I'm unable to provide them a different keys.

However, I will try to figure out if there is a way to solve this problem. Until then as a workaround I suggest applying aliases in selects.

Please let me know if you noticed this behavior outside pg_catalog.

Fabio286 avatar Jul 26 '23 11:07 Fabio286

Thanks for the update. I noticed this behavior outside pg_catalog tables as well.

For example, the below query outputs just one column-

CREATE TABLE employees (id int, name text);

INSERT INTO employees 
VALUES (1, 'abc');


SELECT 
    id,
    id
FROM public.employees;

Output: image

relationaldba avatar Aug 02 '23 14:08 relationaldba

Aliasing the columns does work though :)

image

relationaldba avatar Aug 02 '23 14:08 relationaldba

This also happens with mysql/mariadb with no joins.

designgears avatar Oct 16 '23 17:10 designgears

This also happens with mysql/mariadb with no joins.

Can you give me an example?

Fabio286 avatar Oct 16 '23 18:10 Fabio286

This also happens with mysql/mariadb with no joins.

Can you give me an example?

SELECT some_id, some_id, some_id, other_colum FROM some_table;

designgears avatar Oct 16 '23 18:10 designgears

SELECT some_id, some_id, some_id, other_colum FROM some_table;

In this case is because mysql library returns me an array of objects as results and an object can't have properties with same name.

Fabio286 avatar Oct 17 '23 07:10 Fabio286

SELECT some_id, some_id, some_id, other_colum FROM some_table;

In this case is because mysql library returns me an array of objects as results and an object can't have properties with same name.

Would it make sense to check for duplicates and throw an error instead, or maybe alias it behind the scenes to avoid displaying the table with offset columns?

designgears avatar Oct 17 '23 17:10 designgears