From 245e6b067ae48198869a1498fb3f5d9fa93000b3 Mon Sep 17 00:00:00 2001 From: OverlordQ Date: Fri, 29 Apr 2011 22:27:34 +0000 Subject: [PATCH] Followup to r85907, correctly quote table names. Followup to r87129, add handling of arrayed GROUP BY/ORDER BY options to match core class so that this will indeed work. --- includes/db/DatabasePostgres.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index 521e8c00a8..446fd802d6 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -39,7 +39,7 @@ AND relname=%s AND attname=%s; SQL; - $table = $db->tableName( $table ); + $table = $db->tableName( $table, false ); $res = $db->query( sprintf( $q, $db->addQuotes( $wgDBmwschema ), @@ -819,7 +819,7 @@ class DatabasePostgres extends DatabaseBase { if ( !$schema ) { $schema = $wgDBmwschema; } - $table = $this->tableName( $table ); + $table = $this->tableName( $table, false ); $etable = $this->addQuotes( $table ); $eschema = $this->addQuotes( $schema ); $SQL = "SELECT 1 FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n " @@ -1002,13 +1002,21 @@ SQL; } if ( isset( $options['GROUP BY'] ) ) { - $preLimitTail .= ' GROUP BY ' . $options['GROUP BY']; + $gb = is_array( $options['GROUP BY'] ) + ? implode( ',', $options['GROUP BY'] ) + : $options['GROUP BY']; + $preLimitTail .= " GROUP BY {$gb}"; } + if ( isset( $options['HAVING'] ) ) { $preLimitTail .= " HAVING {$options['HAVING']}"; } + if ( isset( $options['ORDER BY'] ) ) { - $preLimitTail .= ' ORDER BY ' . $options['ORDER BY']; + $ob = is_array( $options['ORDER BY'] ) + ? implode( ',', $options['ORDER BY'] ) + : $options['ORDER BY']; + $preLimitTail .= " ORDER BY {$ob}"; } //if ( isset( $options['LIMIT'] ) ) { -- 2.20.1