Is renaming id's name allowed but unsafe?

irep

New Member
Hello.

Thank you for the last update 3.4.x it's gorgeous ! ;)
I use the new Content type feature, it's great, but the problem I describe here is not linked to it (except it helps me reproduce the issue).

What did I do ? Renaming id's name.

No problem so far, I can save the new name.
Edit 1: Of course I meet this alert, but I click on save and close:
Message
Item successfully saved.
  • Update table field name from `tabxxxelename` to `tabclielename`.
  • Please read carefully any notifications that may appear regarding the update you are about to perform.
  • Then check that the database field's structure and or name are desired.
  • If you are happy to continue press 'Save'
  • Otherwise press 'Cancel', this will revert the element name and plug-in type to the element's setting previous to being edited

But If I want to see or add data I get this error:

Code:
 500 Fabrik has generated an incorrect query for the list tabcli: <br /><br /><pre>Unknown column 'tabcli.tabxxxeleid' in 'field list' SQL=SELECT SQL_CALC_FOUND_ROWS DISTINCT `tabcli`.`tabxxxelename` AS `tabcli___tabxxxelename`, `tabcli`.`tabxxxelename` AS `tabcli___tabxxxelename_raw`, `tabcli`.`tabxxxeledat` AS `tabcli___tabxxxeledat`, `tabcli`.`tabxxxeledat` AS `tabcli___tabxxxeledat_raw`, `tabcli`.`tabclieleid` AS `tabcli___tabclieleid`, `tabcli`.`tabclieleid` AS `tabcli___tabclieleid_raw`, `tabcli`.`tabxxxeleid` AS slug , `tabcli`.`tabxxxeleid` AS `__pk_val` FROM `tabcli` LIMIT 0, 10</pre>

Indeed, in fabrik_lists table there is db_primary_key: tabcli.tabxxxeleid
If I change tabcli.tabxxxeleid in tabcli.tabclieleid the problem is solved.

But I don't feel very secure to do this when I'll have dozens of Fabrik Lists. Is it a bug? Or is it due to permission? I can send you my content type .xml file to reproduce the issue.

Why did I want to change or even customize id's name? Well, that's a good question? ;) Following the tutorial (many to many), I noticed that when I have to make a join (er? table join) I have to choose the From and the To id's. Since they are all named "id" I found it a bit frustrating not knowing which one I chose (even if Fabrik prevents me from choosing the wrong one limiting the list of Elements in the drop-down list).

Dunno if that makes sense?

Thank you.

Edit 1: added the alert message. Please see the first quote above.
Edit 2: My test site runs under Joomla 3.4.8. PHP 5.4.38 Mysql 5.1.73
 
Last edited:
We don't recommend changing the PK element's name. It should work in a simple case, as in the save code for the element we have ...

Code:
        // Are we updating the name of the primary key element?

        if ($row->name === FabrikString::shortColName($item->db_primary_key))
        {
            if ($name !== $row->name)
            {
                // Yes we are so update the table
                $item->db_primary_key = str_replace($row->name, $name, $item->db_primary_key);
                $item->store();
            }
        }

... but there's a number of ways that won't work, for instance if you have copied a list, this is only going to change the one the element is on, and all the other copies are going to break. Or if you have join elements in other lists which point to this one, they also store the PK name in their params. We do use the ID rather than the name in most places we need to reference another element, but in some place that just doesn't work as it involves a lot of overhead to derive the name form the id.

Basically, it's not something we ever do, we don't test and don't recommend, so issues can creep in, and obviously you've discovered one.

I've even thought about just flat out not allowing the PK element name to be changed, as there could be other more subtle problems that don't show up immediately, but down the road you'll find nasty issues have crept in to your data.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top