r90356 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90355‎ | r90356 | r90357 >
Date:18:58, 18 June 2011
Author:mgrabovsky
Status:ok
Tags:
Comment:
(bug 29476) DatabaseBase::deleteJoin fails for Sqlite

Added deleteJoin() to DatabaseSqlite, C&P from DatabasePostgres
Modified paths:
  • /trunk/phase3/includes/db/DatabaseSqlite.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabaseSqlite.php
@@ -544,6 +544,35 @@
545545 }
546546
547547 /**
 548+ * DELETE where the condition is a join
 549+ *
 550+ * @param $delTable String: The table to delete from.
 551+ * @param $joinTable String: The other table.
 552+ * @param $delVar String: The variable to join on, in the first table.
 553+ * @param $joinVar String: The variable to join on, in the second table.
 554+ * @param $conds Array: Condition array of field names mapped to variables, ANDed together in the WHERE clause
 555+ * @param $fname String: Calling function name (use __METHOD__) for logs/profiling
 556+ */
 557+ public function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds,
 558+ $fname = 'DatabaseSqlite::deleteJoin' )
 559+ {
 560+ if ( !$conds ) {
 561+ throw new DBUnexpectedError( $this,
 562+ 'DatabaseSqlite::deleteJoin() called with empty $conds' );
 563+ }
 564+
 565+ $delTable = $this->tableName( $delTable );
 566+ $joinTable = $this->tableName( $joinTable );
 567+ $sql = "DELETE FROM $delTable WHERE $delVar IN (SELECT $joinVar FROM $joinTable";
 568+ if ( $conds != '*' ) {
 569+ $sql .= ' WHERE ' . $this->makeList( $conds, LIST_AND );
 570+ }
 571+ $sql .= ')';
 572+
 573+ $this->query( $sql, $fname );
 574+ }
 575+
 576+ /**
548577 * Returns the size of a text field, or -1 for "unlimited"
549578 * In SQLite this is SQLITE_MAX_LENGTH, by default 1GB. No way to query it though.
550579 *

Follow-up revisions

RevisionCommit summaryAuthorDate
r90363All the databases but MySQL were overriding DatabaseBase::deleteJoin() with t...platonides20:26, 18 June 2011
r90364Follow-up r90356 & r90363: test deleteJoin() on SQLitemaxsem20:37, 18 June 2011

Status & tagging log