Index: trunk/phase3/maintenance/tests/phpunit/includes/db/DatabaseSqliteTest.php |
— | — | @@ -17,22 +17,25 @@ |
18 | 18 | } |
19 | 19 | } |
20 | 20 | |
| 21 | +/** |
| 22 | + * @group sqlite |
| 23 | + */ |
21 | 24 | class DatabaseSqliteTest extends PHPUnit_Framework_TestCase { |
22 | 25 | var $db; |
23 | 26 | |
24 | | - function setup() { |
| 27 | + public function setup() { |
25 | 28 | if ( !Sqlite::isPresent() ) { |
26 | 29 | $this->markTestSkipped( 'No SQLite support detected' ); |
27 | 30 | } |
28 | 31 | $this->db = new MockDatabaseSqlite(); |
29 | 32 | } |
30 | 33 | |
31 | | - function replaceVars( $sql ) { |
| 34 | + private function replaceVars( $sql ) { |
32 | 35 | // normalize spacing to hide implementation details |
33 | 36 | return preg_replace( '/\s+/', ' ', $this->db->replaceVars( $sql ) ); |
34 | 37 | } |
35 | 38 | |
36 | | - function testReplaceVars() { |
| 39 | + public function testReplaceVars() { |
37 | 40 | $this->assertEquals( 'foo', $this->replaceVars( 'foo' ), "Don't break anything accidentally" ); |
38 | 41 | |
39 | 42 | $this->assertEquals( "CREATE TABLE /**/foo (foo_key INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " |
— | — | @@ -58,6 +61,16 @@ |
59 | 62 | $this->replaceVars( "ALTER TABLE foo\nADD COLUMN foo_bar int(10) unsigned DEFAULT 42" ) |
60 | 63 | ); |
61 | 64 | } |
| 65 | + |
| 66 | + public function testTableName() { |
| 67 | + // @todo Moar! |
| 68 | + $db = new DatabaseSqliteStandalone( ':memory:' ); |
| 69 | + $this->assertEquals( 'foo', $db->tableName( 'foo' ) ); |
| 70 | + $this->assertEquals( 'sqlite_master', $db->tableName( 'sqlite_master' ) ); |
| 71 | + $db->tablePrefix( 'foo' ); |
| 72 | + $this->assertEquals( 'sqlite_master', $db->tableName( 'sqlite_master' ) ); |
| 73 | + $this->assertEquals( 'foobar', $db->tableName( 'bar' ) ); |
| 74 | + } |
62 | 75 | |
63 | 76 | function testEntireSchema() { |
64 | 77 | global $IP; |
— | — | @@ -67,4 +80,4 @@ |
68 | 81 | $this->fail( $result ); |
69 | 82 | } |
70 | 83 | } |
71 | | -} |
\ No newline at end of file |
| 84 | +} |
Index: trunk/phase3/includes/db/DatabaseSqlite.php |
— | — | @@ -266,6 +266,8 @@ |
267 | 267 | * Use MySQL's naming (accounts for prefix etc) but remove surrounding backticks |
268 | 268 | */ |
269 | 269 | function tableName( $name ) { |
| 270 | + // table names starting with sqlite_ are reserved |
| 271 | + if ( strpos( $name, 'sqlite_' ) === 0 ) return $name; |
270 | 272 | return str_replace( '`', '', parent::tableName( $name ) ); |
271 | 273 | } |
272 | 274 | |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -329,6 +329,7 @@ |
330 | 330 | instead of alterning focus between the two buttons. |
331 | 331 | * (bug 24987) Special:ListUsers does not take external groups into account |
332 | 332 | * (bug 20633) update.php has mixed language output |
| 333 | +* SQLite system table names are now never prefixed. |
333 | 334 | |
334 | 335 | === API changes in 1.17 === |
335 | 336 | * (bug 22738) Allow filtering by action type on query=logevent. |