Skip to content

Commit

Permalink
fix SQLite hasColumn duplicated table prefix (#22340)
Browse files Browse the repository at this point in the history
  • Loading branch information
abdumu authored and taylorotwell committed Dec 7, 2017
1 parent ea5d6c0 commit 2c47c15
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function compileTableExists()
*/
public function compileColumnListing($table)
{
return 'pragma table_info('.$this->wrapTable(str_replace('.', '__', $table)).')';
return 'pragma table_info('.str_replace('.', '__', $table).')';
}

/**
Expand Down
12 changes: 12 additions & 0 deletions tests/Database/DatabaseSchemaBuilderIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,16 @@ public function testDropAllTablesWorksWithForeignKeys()
$this->assertFalse($this->db->connection()->getSchemaBuilder()->hasTable('table1'));
$this->assertFalse($this->db->connection()->getSchemaBuilder()->hasTable('table2'));
}

public function testHasColumnWithTablePrefix()
{
$this->db->connection()->setTablePrefix('test_');

$this->db->connection()->getSchemaBuilder()->create('table1', function ($table) {
$table->integer('id');
$table->string('name');
});

$this->assertTrue($this->db->connection()->getSchemaBuilder()->hasColumn('table1', 'name'));
}
}

0 comments on commit 2c47c15

Please sign in to comment.