r77271 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77270‎ | r77271 | r77272 >
Date:07:39, 25 November 2010
Author:mah
Status:reverted
Tags:
Comment:
Give SQLite a translation for MySQL's UNIX_TIMESTAMP() functions. Pg will probably need something similar.
Modified paths:
  • /trunk/phase3/includes/db/Database.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseSqlite.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/Database.php
@@ -597,6 +597,14 @@
598598 }
599599
600600 /**
 601+ * Database specific translations like MySQL's UNIX_TIMESTAMP() to
 602+ * something the DB can use.
 603+ */
 604+ function translateSQLFunctions( $vars ) {
 605+ return $vars;
 606+ }
 607+
 608+ /**
601609 * Usually aborts on failure. If errors are explicitly ignored, returns success.
602610 *
603611 * @param $sql String: SQL query
@@ -650,7 +658,7 @@
651659 } else {
652660 $userName = '';
653661 }
654 - $commentedSql = preg_replace( '/\s/', " /* $fname $userName */ ", $sql, 1 );
 662+ $commentedSql = $this->translateSQLFunctions( preg_replace( '/\s/', " /* $fname $userName */ ", $sql, 1 ) );
655663 # } else {
656664 # $commentedSql = $sql;
657665 # }
Index: trunk/phase3/includes/db/DatabaseSqlite.php
@@ -364,6 +364,15 @@
365365 }
366366
367367 /**
 368+ * Database specific translations like MySQL's UNIX_TIMESTAMP() to
 369+ * something the DB can use.
 370+ */
 371+ function translateSQLFunctions( $vars ) {
 372+ return preg_replace( '/UNIX_TIMESTAMP\(([^()]+)\)/', 'strftime("%s",\1)', $vars );
 373+ }
 374+
 375+
 376+ /**
368377 * Based on generic method (parent) with some prior SQLite-sepcific adjustments
369378 */
370379 function insert( $table, $a, $fname = 'DatabaseSqlite::insert', $options = array() ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r77272Simplify the SQL setup code, maka schema createion work on SQLite and, with r...mah07:46, 25 November 2010
r77317revert r77271 since it was an expensive fix to a non-existant problem.mah02:37, 26 November 2010

Status & tagging log