From 3c224e54ac10b008309c2cd9876e5d9c3c026879 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Sat, 14 Aug 2010 11:24:07 +0000 Subject: [PATCH] Make NATURAL JOINs possible --- includes/db/Database.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/includes/db/Database.php b/includes/db/Database.php index 54eb32c317..4770293c9f 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -1428,7 +1428,10 @@ abstract class DatabaseBase { if ( isset($join_conds_safe[$table]) && isset($use_index_safe[$table]) ) { $tableClause = $join_conds_safe[$table][0] . ' ' . $this->tableName( $table ); $tableClause .= ' ' . $this->useIndexClause( implode( ',', (array)$use_index_safe[$table] ) ); - $tableClause .= ' ON (' . $this->makeList((array)$join_conds_safe[$table][1], LIST_AND) . ')'; + $on = $this->makeList((array)$join_conds_safe[$table][1], LIST_AND); + if ( $on != '' ) { + $tableClause .= ' ON (' . $on . ')'; + } $retJOIN[] = $tableClause; // Is there an INDEX clause? } else if ( isset($use_index_safe[$table]) ) { @@ -1438,7 +1441,10 @@ abstract class DatabaseBase { // Is there a JOIN clause? } else if ( isset($join_conds_safe[$table]) ) { $tableClause = $join_conds_safe[$table][0] . ' ' . $this->tableName( $table ); - $tableClause .= ' ON (' . $this->makeList((array)$join_conds_safe[$table][1], LIST_AND) . ')'; + $on = $this->makeList((array)$join_conds_safe[$table][1], LIST_AND); + if ( $on != '' ) { + $tableClause .= ' ON (' . $on . ')'; + } $retJOIN[] = $tableClause; } else { $tableClause = $this->tableName( $table ); -- 2.20.1