r47086 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47085‎ | r47086 | r47087 >
Date:13:57, 10 February 2009
Author:mkroetzsch
Status:deferred
Tags:
Comment:
GROUP BY should encompass all SELECTED non-aggregate rows (even though MySQL does not complain either way)
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php
@@ -937,18 +937,18 @@
938938 $options .= ' OFFSET ' . $requestoptions->offset;
939939 }
940940 // NOTE: the query needs to do the fitlering of internal properties, else LIMIT is wrong
941 - $res = $db->query('(SELECT smw_id, smw_title, COUNT(*) as count, smw_sortkey FROM ' .
 941+ $res = $db->query('(SELECT smw_id, smw_title, smw_sortkey, COUNT(*) as count FROM ' .
942942 $db->tableName('smw_rels2') . ' INNER JOIN ' . $db->tableName('smw_ids') . ' ON p_id=smw_id WHERE smw_iw=' .
943 - $db->addQuotes('') . ' OR smw_iw=' . $db->addQuotes(SMW_SQL2_SMWPREDEFIW) . ' GROUP BY smw_id) UNION ' .
 943+ $db->addQuotes('') . ' OR smw_iw=' . $db->addQuotes(SMW_SQL2_SMWPREDEFIW) . ' GROUP BY smw_id,smw_title,smw_sortkey) UNION ' .
944944 '(SELECT smw_id, smw_title, COUNT(*) as count, smw_sortkey FROM ' .
945945 $db->tableName('smw_spec2') . ' INNER JOIN ' . $db->tableName('smw_ids') . ' ON p_id=smw_id WHERE smw_iw=' .
946 - $db->addQuotes('') . ' OR smw_iw=' . $db->addQuotes(SMW_SQL2_SMWPREDEFIW) . ' GROUP BY smw_id) UNION ' .
 946+ $db->addQuotes('') . ' OR smw_iw=' . $db->addQuotes(SMW_SQL2_SMWPREDEFIW) . ' GROUP BY smw_id,smw_title,smw_sortkey) UNION ' .
947947 '(SELECT smw_id, smw_title, COUNT(*) as count, smw_sortkey FROM ' .
948948 $db->tableName('smw_atts2') . ' INNER JOIN ' . $db->tableName('smw_ids') . ' ON p_id=smw_id WHERE smw_iw=' .
949 - $db->addQuotes('') . ' OR smw_iw=' . $db->addQuotes(SMW_SQL2_SMWPREDEFIW) . ' GROUP BY smw_id) UNION ' .
 949+ $db->addQuotes('') . ' OR smw_iw=' . $db->addQuotes(SMW_SQL2_SMWPREDEFIW) . ' GROUP BY smw_id,smw_title,smw_sortkey) UNION ' .
950950 '(SELECT smw_id, smw_title, COUNT(*) as count, smw_sortkey FROM ' .
951951 $db->tableName('smw_text2') . ' INNER JOIN ' . $db->tableName('smw_ids') . ' ON p_id=smw_id WHERE smw_iw=' .
952 - $db->addQuotes('') . ' OR smw_iw=' . $db->addQuotes(SMW_SQL2_SMWPREDEFIW) . ' GROUP BY smw_id) ' . $options,
 952+ $db->addQuotes('') . ' OR smw_iw=' . $db->addQuotes(SMW_SQL2_SMWPREDEFIW) . ' GROUP BY smw_id,smw_title,smw_sortkey) ' . $options,
953953 'SMW::getPropertySubjects');
954954 $result = array();
955955 while($row = $db->fetchObject($res)) {

Status & tagging log