Skip to content

Commit

Permalink
add postgres table escaping and regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
laurencei committed Mar 31, 2017
1 parent 12dad33 commit f55331d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function compileDropIfExists(Blueprint $blueprint, Fluent $command)
*/
public function compileDropAllTables($tables)
{
return 'drop table '.implode(',', $tables).' cascade';
return 'drop table "'.implode('","', $tables).'" cascade';
}

/**
Expand Down
7 changes: 7 additions & 0 deletions tests/Database/DatabasePostgresSchemaGrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,13 @@ public function testAddingMacAddress()
$this->assertEquals('alter table "users" add column "foo" macaddr not null', $statements[0]);
}

public function testDropAllTablesEscapesTableNames()
{
$statement = $this->getGrammar()->compileDropAllTables(['alpha', 'beta', 'gamma']);

$this->assertEquals('drop table "alpha","beta","gamma" cascade', $statement);
}

protected function getConnection()
{
return m::mock('Illuminate\Database\Connection');
Expand Down

0 comments on commit f55331d

Please sign in to comment.