1
0
mirror of synced 2025-01-18 14:31:40 +03:00

[2.0] Cleanup

This commit is contained in:
jwage 2009-06-20 17:02:02 +00:00
parent 78d43097ca
commit 61555c78d2
5 changed files with 35 additions and 48 deletions

View File

@ -45,9 +45,22 @@ class Driver implements \Doctrine\DBAL\Driver
*/
private function _constructPdoDsn(array $params)
{
//TODO
// TODO: This might need to be revisted once we have access to a mssql server
$dsn = 'mssql:';
if (isset($params['host'])) {
$dsn .= 'host=' . $params['host'] . ';';
}
if (isset($params['port'])) {
$dsn .= 'port=' . $params['port'] . ';';
}
if (isset($params['dbname'])) {
$dsn .= 'dbname=' . $params['dbname'] . ';';
}
return $dsn;
}
public function getDatabasePlatform()
{
return new \Doctrine\DBAL\Platforms\MsSqlPlatform();

View File

@ -233,6 +233,11 @@ class OraclePlatform extends AbstractPlatform
return "SELECT name FROM sys.user_source WHERE line = 1 AND type = 'FUNCTION'";
}
public function getListSequencesSql($database)
{
return 'SELECT sequence_name FROM sys.user_sequences';
}
public function getCreateTableSql($table, array $columns, array $options = array())
{
$indexes = isset($options['indexes']) ? $options['indexes']:array();

View File

@ -199,9 +199,7 @@ class OracleSchemaManager extends AbstractSchemaManager
{
$sql = $this->_platform->getDropAutoincrementSql($table);
foreach ($sql as $query) {
try {
$this->_conn->exec($query);
} catch (\Exception $e) {}
$this->_conn->exec($query);
}
return true;
@ -237,28 +235,8 @@ class OracleSchemaManager extends AbstractSchemaManager
public function dropTable($name)
{
try {
$this->dropAutoincrement($name);
} catch (\Exception $e) {
//FIXME: Exception silencing ;'-(
}
$this->dropAutoincrement($name);
return parent::dropTable($name);
}
/**
* Lists all sequences.
*
* @param string|null $database
* @return array
*/
public function listSequences($database = null)
{
//FIXME: $database not used. Remove?
$query = "SELECT sequence_name FROM sys.user_sequences";
$tableNames = $this->_conn->fetchColumn($query);
return $tableNames;
}
}

View File

@ -52,10 +52,15 @@ class SqliteSchemaManager extends AbstractSchemaManager
*/
public function createDatabase($database)
{
// FIXME: $database parameter not used
// TODO: Can we do this better?
$this->_conn->close();
$this->_conn->connect();
$params = $this->_conn->getParams();
$driver = $params['driver'];
$options = array(
'driver' => $driver,
'path' => $database
);
$conn = \Doctrine\DBAL\DriverManager::getConnection($options);
$conn->connect();
$conn->close();
}
protected function _getPortableTableDefinition($table)

View File

@ -119,28 +119,15 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this->assertEquals('CREATE VIEW test_create_view AS SELECT * from test_views', $views[0]['sql']);
}
/* FIXME: Using ORM in DBAL test suite. Not OK!!
public function testCreateAndDropDatabase()
{
$path = dirname(__FILE__).'/test_create_and_drop_sqlite_database.sqlite';
$config = new \Doctrine\ORM\Configuration();
$eventManager = new \Doctrine\Common\EventManager();
$connectionOptions = array(
'driver' => 'pdo_sqlite',
'path' => $path
);
$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config, $eventManager);
$conn = $em->getConnection();
$sm = $conn->getSchemaManager();
$sm->createDatabase();
$this->_sm->createDatabase($path);
$this->assertEquals(true, file_exists($path));
$sm->dropDatabase();
$this->_sm->dropDatabase($path);
$this->assertEquals(false, file_exists($path));
$sm->createDatabase();
$this->assertEquals(true, file_exists($path));
$sm->dropDatabase();
}*/
}
public function testCreateTable()
{
@ -176,8 +163,7 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
$this->_sm->createSequence('seqname', 1, 1);
}
/* FIXME: See comment in AbstractSchemaManager#dropIndex($table, $name)
public function testCreateIndex()
{
$this->createTestTable('test_create_index');
@ -193,7 +179,7 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
$tableIndexes = $this->_sm->listTableIndexes('test_create_index');
$this->assertEquals('test', $tableIndexes[0]['name']);
$this->assertEquals(true, $tableIndexes[0]['unique']);
}*/
}
/**
* @expectedException \Exception