Using the Contacts editor in Joomla 3.6.4, edit any contact which has tags that will populate the tag ordering page.
Contact edit page should correctly render and populate screen including tag ordering tab.
Rendering of contact edit page fails.
Error Code: 1052 Column 'name' in group statement is ambiguous is displayed in browser tab header.
Joomla 3.6.4 PHP any version from 5.3.10 onwards including PHP 7.
Error is in /libraries/cms/helper/tags.php line 622.
Generated group clause for SQL select statement should qualify field names with table aliases.
Error is solved by adding table alias 'ua' to field 'name' i.e. 'ua.name'.
Status | New | ⇒ | Information Required |
I am closing this due to a lack of response. It can always be reopened if the requested information is provided.
Status | Information Required | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-12-09 12:29:16 |
Closed_By | ⇒ | brianteeman |
The issue is still present in Joomla! 3.7.4. It's not a problem now but it's a problem waiting to arise...
The group clause in libraries/cms/helper/tags.php @ row 637 should use the field "author" not "name":
->group('m.type_alias, m.content_item_id, m.core_content_id, core_modified_time, core_created_time, core_created_by_alias, author, author_email');
To understand the issue:
Create some contacts, with ad associated tag.
Create a menu-item of type Tagged elements (blog).
If you want the blog-view to be able to show some additional contact info you have to modify the model deriving the class model or via a model-override, using MVC plugin, to join the fields you need.
Let's use MVC plugin; copy components/com_tags/models/tag.php in /code dir and add these lines @ row 157 to join the telephone field:
$typesarray = $tagsHelper::getTypes('assocList', $typesr, false);
foreach ($typesarray as $type) {
if ('com_contact.contact' == $type['type_alias']) {
$query->join('LEFT', $this->_db->quoteName('#__contact_details', 'cd') . ' ON (' . $this->_db->quoteName('c.core_title') . ' = ' . $this->_db->quoteName('cd.name') . ')');
$query->select('cd.name AS cd_name, cd.telephone AS cd_telephone, ');
break;
}
}
The query will fail with error: Column 'name' in group statement is ambiguous.
Yes, at the moment the problem won't arise in standard joomla installation.
It arises only in a slightly extended Joomla scenario, in a just non-trivial Joomla application (when a class is derived or the tags model is overriden via MVC plugin to show some additional contacts field).
Anyway it seems that is NOT A GOOD PRACTICE to have a SELECT correctly renaming a field (as in libraries/cms/helper/tags.php @ row 599: "...ua.name END AS author") and later on using the non-renamed and not-table-qualified column 'name'.
It is an ERROR WAITING TO ARISE.
For a better practice the group clause in libraries/cms/helper/tags.php @ row 637 should use the field "author" not "name"; it should read:
->group('m.type_alias, m.content_item_id, m.core_content_id, core_modified_time, core_created_time, core_created_by_alias, author, author_email');
At the moment, if you override the model as described above, inserting a join such as the proposed one, you have to fix the query error via a text substitution, immediately after the above join:
$query->setQuery(str_replace(' name, ', ' author, ', $query));
I think this should be 'fixed'
@LivioCavallo this is a issue closed back in 2016 can you please open a new issue or pull request with the suggested changes?
I never did a pull request or submitted a new issue. Now I try to submit a new issue
You can go here: https://github.com/joomla/joomla-cms/issues/new
Thanks! Looks good to me.
Can you provide some more details please - perhaps with screenshots. I
tried to replicate the issue described but had no problems
On 18 November 2016 at 11:55, altcom-jc notifications@github.com wrote:
Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
https://brian.teeman.net/ http://brian.teeman.net/