Skip to content

Commit

Permalink
Add dropTableSql to Postgres.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed May 25, 2013
1 parent 59dd147 commit c21a185
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/Cake/Database/Schema/PostgresSchema.php
Expand Up @@ -332,4 +332,14 @@ public function createTableSql(Table $table, $columns, $constraints, $indexes) {
return $out;
}

/**
* Generate the SQL to drop a table.
*
* @param Cake\Database\Schema\Table $table Table instance
* @return string DROP TABLE sql
*/
public function dropTableSql(Table $table) {
return sprintf('DROP TABLE "%s"', $table->name());
}

}
16 changes: 16 additions & 0 deletions lib/Cake/Test/TestCase/Database/Schema/PostgresSchemaTest.php
Expand Up @@ -545,6 +545,22 @@ public function testCreateTableSql() {
);
}

/**
* test dropTableSql
*
* @return void
*/
public function testDropTableSql() {
$driver = $this->_getMockedDriver();
$connection = $this->getMock('Cake\Database\Connection', array(), array(), '', false);
$connection->expects($this->any())->method('driver')
->will($this->returnValue($driver));

$table = new Table('articles');
$result = $table->dropTableSql($connection);
$this->assertEquals('DROP TABLE "articles"', $result);
}

/**
* Get a schema instance with a mocked driver/pdo instances
*
Expand Down

0 comments on commit c21a185

Please sign in to comment.