Changed use of tag_summary to use change_tag with GROUP_CONCAT()
* Added buildGroupConcatField() method to the DB classes bug: 53577 Change-Id: I976f297653880e66af429ba9b622a954fefcc512
This commit is contained in:
parent
2a0da3b558
commit
a97402559b
5 changed files with 47 additions and 4 deletions
|
|
@ -193,10 +193,9 @@ class ChangeTags {
|
|||
throw new MWException( 'Unable to determine appropriate JOIN condition for tagging.' );
|
||||
}
|
||||
|
||||
// JOIN on tag_summary
|
||||
$tables[] = 'tag_summary';
|
||||
$join_conds['tag_summary'] = array( 'LEFT JOIN', "ts_$join_cond=$join_cond" );
|
||||
$fields[] = 'ts_tags';
|
||||
$fields['ts_tags'] = wfGetDB( DB_SLAVE )->buildGroupConcatField(
|
||||
',', 'change_tag', 'ct_tag', "ct_$join_cond=$join_cond"
|
||||
);
|
||||
|
||||
if ( $wgUseTagFilter && $filter_tag ) {
|
||||
// Somebody wants to filter on a tag.
|
||||
|
|
|
|||
|
|
@ -2079,6 +2079,29 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
|
|||
return 'CONCAT(' . implode( ',', $stringList ) . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a GROUP_CONCAT or equivalent statement for a query.
|
||||
*
|
||||
* This is useful for combining a field for several rows into a single string.
|
||||
* NULL values will not appear in the output, duplicated values will appear,
|
||||
* and the resulting delimiter-separated values have no defined sort order.
|
||||
* Code using the results may need to use the PHP unique() or sort() methods.
|
||||
*
|
||||
* @param string $delim Glue to bind the results together
|
||||
* @param string|array $table Table name
|
||||
* @param string $field Field name
|
||||
* @param string|array $conds Conditions
|
||||
* @param string|array $join_conds Join conditions
|
||||
* @return String SQL text
|
||||
* @since 1.23
|
||||
*/
|
||||
public function buildGroupConcatField(
|
||||
$delim, $table, $field, $conds = '', $join_conds = array()
|
||||
) {
|
||||
$fld = "GROUP_CONCAT($field SEPARATOR " . $this->addQuotes( $delim ) . ')';
|
||||
return '(' . $this->selectSQLText( $table, $fld, $conds, null, array(), $join_conds ) . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the current database
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1354,6 +1354,13 @@ class DatabaseOracle extends DatabaseBase {
|
|||
return $this->mServer;
|
||||
}
|
||||
|
||||
public function buildGroupConcatField(
|
||||
$delim, $table, $field, $conds = '', $join_conds = array()
|
||||
) {
|
||||
$fld = "LISTAGG($field," . $this->addQuotes( $delim ) . ") WITHIN GROUP (ORDER BY $field)";
|
||||
return '(' . $this->selectSQLText( $table, $fld, $conds, null, array(), $join_conds ) . ')';
|
||||
}
|
||||
|
||||
public function getSearchEngine() {
|
||||
return 'SearchOracle';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1431,6 +1431,13 @@ SQL;
|
|||
return implode( ' || ', $stringList );
|
||||
}
|
||||
|
||||
public function buildGroupConcatField(
|
||||
$delimiter, $table, $field, $conds = '', $options = array(), $join_conds = array()
|
||||
) {
|
||||
$fld = "array_to_string(array_agg($field)," . $this->addQuotes( $delimiter ) . ')';
|
||||
return '(' . $this->selectSQLText( $table, $fld, $conds, null, array(), $join_conds ) . ')';
|
||||
}
|
||||
|
||||
public function getSearchEngine() {
|
||||
return 'SearchPostgres';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -828,6 +828,13 @@ class DatabaseSqlite extends DatabaseBase {
|
|||
return '(' . implode( ') || (', $stringList ) . ')';
|
||||
}
|
||||
|
||||
public function buildGroupConcatField(
|
||||
$delim, $table, $field, $conds = '', $join_conds = array()
|
||||
) {
|
||||
$fld = "group_concat($field," . $this->addQuotes( $delim ) . ')';
|
||||
return '(' . $this->selectSQLText( $table, $fld, $conds, null, array(), $join_conds ) . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws MWException
|
||||
* @param $oldName
|
||||
|
|
|
|||
Loading…
Reference in a new issue