diff --git a/administrator/components/com_content/models/articles.php b/administrator/components/com_content/models/articles.php index 994e4b9b0baf5..6d8bbde669b78 100644 --- a/administrator/components/com_content/models/articles.php +++ b/administrator/components/com_content/models/articles.php @@ -210,7 +210,7 @@ protected function getListQuery() ->join('LEFT', '#__categories AS c ON c.id = a.catid'); // Join over the parent categories. - $query->select('parent.title AS parent_category_title, parent.id AS parent_category_id, + $query->select('parent.title AS parent_category_title, parent.id AS parent_category_id, parent.created_user_id AS parent_category_uid, parent.level AS parent_category_level') ->join('LEFT', '#__categories AS parent ON parent.id = c.parent_id'); @@ -224,7 +224,7 @@ protected function getListQuery() if (JPluginHelper::isEnabled('content', 'vote')) { $assogroup .= ', v.rating_sum, v.rating_count'; - $query->select('COALESCE(NULLIF(ROUND(v.rating_sum / v.rating_count, 0), 0), 0) AS rating, + $query->select('COALESCE(NULLIF(ROUND(v.rating_sum / v.rating_count, 0), 0), 0) AS rating, COALESCE(NULLIF(v.rating_count, 0), 0) as rating_count') ->join('LEFT', '#__content_rating AS v ON a.id = v.content_id'); } @@ -232,9 +232,9 @@ protected function getListQuery() // Join over the associations. if (JLanguageAssociations::isEnabled()) { - $query->select('COUNT(asso2.id)>1 as association') + $query->select('CASE WHEN COUNT(asso2.id)>1 THEN 1 ELSE 0 END as association') ->join('LEFT', '#__associations AS asso ON asso.id = a.id AND asso.context=' . $db->quote('com_content.item')) - ->join('LEFT', '#__associations AS asso2 ON asso2.key = asso.key') + ->join('LEFT', '#__associations AS asso2 ON ' . $db->quoteName('asso2.key') . ' = ' . $db->quoteName('asso.key')) ->group($assogroup); } diff --git a/installation/sql/sqlazure/joomla.sql b/installation/sql/sqlazure/joomla.sql index c895aec194720..c0d9c23716e20 100644 --- a/installation/sql/sqlazure/joomla.sql +++ b/installation/sql/sqlazure/joomla.sql @@ -98,7 +98,7 @@ INSERT INTO "#__assets" ("id", "parent_id", "lft", "rgt", "level", "name", "titl (55, 18, 72, 73, 2, 'com_modules.module.87', 'Sample Data', '{}'), (56, 1, 109, 110, 1, 'com_privacy', 'com_privacy', '{}'), (57, 1, 111, 112, 1, 'com_actionlogs', 'com_actionlogs', '{}'), -(58, 18, 74, 75, 2, 'com_modules.module.88', 'Latest Actions', '{}'); +(58, 18, 74, 75, 2, 'com_modules.module.88', 'Latest Actions', '{}'), (59, 18, 76, 77, 2, 'com_modules.module.89', 'Privacy Dashboard', '{}'); SET IDENTITY_INSERT "#__assets" OFF; diff --git a/libraries/joomla/database/query/sqlsrv.php b/libraries/joomla/database/query/sqlsrv.php index d1b473e3cffd1..2aaafa0cccc67 100644 --- a/libraries/joomla/database/query/sqlsrv.php +++ b/libraries/joomla/database/query/sqlsrv.php @@ -233,7 +233,7 @@ public function __toString() * * Ensure that the value is properly quoted before passing to the method. * - * @param string $value The value to cast as a char. + * @param string $value The value to cast as a char. * * @param string $len The lenght of the char. * @@ -244,7 +244,7 @@ public function __toString() public function castAsChar($value, $len = null) { if (!$len) - { + { return 'CAST(' . $value . ' as NVARCHAR(30))'; } else @@ -812,6 +812,14 @@ protected function fixGroupColumns($selectColumns) continue; } + if ($i == 0 && stripos(' DISTINCT ALL ', " $column[0] ") !== false) + { + // These words are reserved, they are not column names + array_shift($selectColumns[0]); + array_shift($column); + $size--; + } + if ($size > 2 && $column[$size - 2] === 'AS') { // Save and remove AS alias diff --git a/libraries/src/Language/Associations.php b/libraries/src/Language/Associations.php index 50e06657873df..e950c5df069f2 100644 --- a/libraries/src/Language/Associations.php +++ b/libraries/src/Language/Associations.php @@ -56,7 +56,7 @@ public static function getAssociations($extension, $tablename, $context, $id, $p ->select($db->quoteName('c2.language')) ->from($db->quoteName($tablename, 'c')) ->join('INNER', $db->quoteName('#__associations', 'a') . ' ON a.id = c.' . $db->quoteName($pk) . ' AND a.context=' . $db->quote($context)) - ->join('INNER', $db->quoteName('#__associations', 'a2') . ' ON a.key = a2.key') + ->join('INNER', $db->quoteName('#__associations', 'a2') . ' ON ' . $db->quoteName('a.key') . ' = ' . $db->quoteName('a2.key')) ->join('INNER', $db->quoteName($tablename, 'c2') . ' ON a2.id = c2.' . $db->quoteName($pk) . $categoriesExtraSql); // Use alias field ?