r70968 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70967‎ | r70968 | r70969 >
Date:16:28, 12 August 2010
Author:maxsem
Status:ok
Tags:
Comment:
DatabaseSqlite::sourceStream(): convert CHAR types, allow more spaces
Modified paths:
  • /trunk/phase3/includes/db/DatabaseSqlite.php (modified) (history)
  • /trunk/phase3/maintenance/tests/DatabaseSqliteTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/DatabaseSqliteTest.php
@@ -36,9 +36,9 @@
3737 $this->assertEquals( 'foo', $this->replaceVars( 'foo' ), "Don't break anything accidentally" );
3838
3939 $this->assertEquals( "CREATE TABLE /**/foo (foo_key INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "
40 - . "foo_name TEXT NOT NULL DEFAULT '', foo_int INTEGER, foo_int2 INTEGER );",
 40+ . "foo_bar TEXT, foo_name TEXT NOT NULL DEFAULT '', foo_int INTEGER, foo_int2 INTEGER );",
4141 $this->replaceVars( "CREATE TABLE /**/foo (foo_key int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
42 - foo_name varchar(255) binary NOT NULL DEFAULT '', foo_int tinyint( 8 ), foo_int2 int(16) ) ENGINE=MyISAM;" )
 42+ foo_bar char(13), foo_name varchar(255) binary NOT NULL DEFAULT '', foo_int tinyint ( 8 ), foo_int2 int(16) ) ENGINE=MyISAM;" )
4343 );
4444
4545 $this->assertEquals( "CREATE TABLE foo ( foo_binary1 BLOB, foo_binary2 BLOB );",
Index: trunk/phase3/includes/db/DatabaseSqlite.php
@@ -572,9 +572,9 @@
573573 // no such thing as unsigned
574574 $s = preg_replace( '/\b(un)?signed\b/i', '', $s );
575575 // INT -> INTEGER
576 - $s = preg_replace( '/\b(tiny|small|medium|big|)int(\([\s\d]*\)|\b)/i', 'INTEGER', $s );
 576+ $s = preg_replace( '/\b(tiny|small|medium|big|)int(\s*\([\s\d]*\)|\b)/i', 'INTEGER', $s );
577577 // varchar -> TEXT
578 - $s = preg_replace( '/\bvarchar\(\d+\)/i', 'TEXT', $s );
 578+ $s = preg_replace( '/\b(var)?char\s*\(.*?\)/i', 'TEXT', $s );
579579 // TEXT normalization
580580 $s = preg_replace( '/\b(tiny|medium|long)text\b/i', 'TEXT', $s );
581581 // BLOB normalization

Status & tagging log