Menu

#4522 (ok 4.2.8) Duplicate column names while assigning index

4.2.7
fixed
None
1
2014-08-31
2014-08-22
Ronak Patel
No

I am assigning index for cus_id. But, in original table there is only 1 id field.
Why is it showing 2 ids?

1 Attachments

Discussion

  • Marc Delisle

    Marc Delisle - 2014-08-23

    Please
    - tell us which phpMyAdmin version you're using
    - attach a small export of the structure for the customers table and the one on which you are adding a relation on the screenshot

     
  • Marc Delisle

    Marc Delisle - 2014-08-24
    • status: open --> pending
     
  • Alexander Kamp

    Alexander Kamp - 2014-08-25

    I am able to reproduce the duplicated column in 'relations view', but due lack of information I can't confirm it is Rokak' issue.

    It occurs when a table field has a PRIMARY KEY and UNIQUE index on it.
    After selecting the 'destination_table' (in relations view), a ajax query is executed and it contains the duplicated entries.

    The source of this issue is function getUniqueColumns() in Table.class.php (line 1424-1447).

    To prevent duplicated field names a filter (like the in_array function) can be applied.
    In case you apply it on the source you have to test 2 other scenarios. The function is used 2 more times in tbl_relation.lib.php.

    I made a quick/cosmetic fix this issue in tbl_relation.lib.php - add after line 619

    619 foreach ($table_obj->getUniqueColumns(false, false) as $column) {
    +++ if (!in_array($column,$columns))
    620 $columns[] = htmlspecialchars($column);
    621 }

    But better is to solve it at the source.

     
  • Ronak Patel

    Ronak Patel - 2014-08-25

    Hello,
    I found the problem. Actually, I added 2 indexes on id column in customers table.
    One is PRIMARY and other is UNIQUE. I have removed UNIQUE from that column.
    Thanks for your efforts.

     
  • Marc Delisle

    Marc Delisle - 2014-08-25
    • status: pending --> open
    • Group: 3.3.7 --> 4.2.7
     
  • Marc Delisle

    Marc Delisle - 2014-08-25
    • assigned_to: Marc Delisle
     
  • Marc Delisle

    Marc Delisle - 2014-08-25
    • summary: Duplicate column names while assigning index --> (ok 4.2.8) Duplicate column names while assigning index
    • status: open --> resolved
     
  • Marc Delisle

    Marc Delisle - 2014-08-31
    • Status: resolved --> fixed