diff --git a/lib/Doctrine/DBAL/Driver/PDOMsSql/Driver.php b/lib/Doctrine/DBAL/Driver/PDOMsSql/Driver.php index 9501b7c17..347a52e23 100644 --- a/lib/Doctrine/DBAL/Driver/PDOMsSql/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOMsSql/Driver.php @@ -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(); diff --git a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php index 8db4f2210..5abbc4c85 100644 --- a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php @@ -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(); diff --git a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php index d992e9261..e8a098602 100644 --- a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php @@ -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; - } } \ No newline at end of file diff --git a/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php b/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php index 57b3522a4..75b02ff54 100644 --- a/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php @@ -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) diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php index 3c95bd117..feb7ef24a 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php @@ -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