[2.0] Cleanup
This commit is contained in:
parent
78d43097ca
commit
61555c78d2
@ -45,9 +45,22 @@ class Driver implements \Doctrine\DBAL\Driver
|
|||||||
*/
|
*/
|
||||||
private function _constructPdoDsn(array $params)
|
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()
|
public function getDatabasePlatform()
|
||||||
{
|
{
|
||||||
return new \Doctrine\DBAL\Platforms\MsSqlPlatform();
|
return new \Doctrine\DBAL\Platforms\MsSqlPlatform();
|
||||||
|
@ -233,6 +233,11 @@ class OraclePlatform extends AbstractPlatform
|
|||||||
return "SELECT name FROM sys.user_source WHERE line = 1 AND type = 'FUNCTION'";
|
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())
|
public function getCreateTableSql($table, array $columns, array $options = array())
|
||||||
{
|
{
|
||||||
$indexes = isset($options['indexes']) ? $options['indexes']:array();
|
$indexes = isset($options['indexes']) ? $options['indexes']:array();
|
||||||
|
@ -199,9 +199,7 @@ class OracleSchemaManager extends AbstractSchemaManager
|
|||||||
{
|
{
|
||||||
$sql = $this->_platform->getDropAutoincrementSql($table);
|
$sql = $this->_platform->getDropAutoincrementSql($table);
|
||||||
foreach ($sql as $query) {
|
foreach ($sql as $query) {
|
||||||
try {
|
$this->_conn->exec($query);
|
||||||
$this->_conn->exec($query);
|
|
||||||
} catch (\Exception $e) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -237,28 +235,8 @@ class OracleSchemaManager extends AbstractSchemaManager
|
|||||||
|
|
||||||
public function dropTable($name)
|
public function dropTable($name)
|
||||||
{
|
{
|
||||||
try {
|
$this->dropAutoincrement($name);
|
||||||
$this->dropAutoincrement($name);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
//FIXME: Exception silencing ;'-(
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::dropTable($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;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -52,10 +52,15 @@ class SqliteSchemaManager extends AbstractSchemaManager
|
|||||||
*/
|
*/
|
||||||
public function createDatabase($database)
|
public function createDatabase($database)
|
||||||
{
|
{
|
||||||
// FIXME: $database parameter not used
|
$params = $this->_conn->getParams();
|
||||||
// TODO: Can we do this better?
|
$driver = $params['driver'];
|
||||||
$this->_conn->close();
|
$options = array(
|
||||||
$this->_conn->connect();
|
'driver' => $driver,
|
||||||
|
'path' => $database
|
||||||
|
);
|
||||||
|
$conn = \Doctrine\DBAL\DriverManager::getConnection($options);
|
||||||
|
$conn->connect();
|
||||||
|
$conn->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _getPortableTableDefinition($table)
|
protected function _getPortableTableDefinition($table)
|
||||||
|
@ -119,28 +119,15 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
|
|||||||
$this->assertEquals('CREATE VIEW test_create_view AS SELECT * from test_views', $views[0]['sql']);
|
$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()
|
public function testCreateAndDropDatabase()
|
||||||
{
|
{
|
||||||
$path = dirname(__FILE__).'/test_create_and_drop_sqlite_database.sqlite';
|
$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));
|
$this->assertEquals(true, file_exists($path));
|
||||||
$sm->dropDatabase();
|
$this->_sm->dropDatabase($path);
|
||||||
$this->assertEquals(false, file_exists($path));
|
$this->assertEquals(false, file_exists($path));
|
||||||
$sm->createDatabase();
|
}
|
||||||
$this->assertEquals(true, file_exists($path));
|
|
||||||
$sm->dropDatabase();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public function testCreateTable()
|
public function testCreateTable()
|
||||||
{
|
{
|
||||||
@ -176,8 +163,7 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
|
|||||||
{
|
{
|
||||||
$this->_sm->createSequence('seqname', 1, 1);
|
$this->_sm->createSequence('seqname', 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: See comment in AbstractSchemaManager#dropIndex($table, $name)
|
|
||||||
public function testCreateIndex()
|
public function testCreateIndex()
|
||||||
{
|
{
|
||||||
$this->createTestTable('test_create_index');
|
$this->createTestTable('test_create_index');
|
||||||
@ -193,7 +179,7 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
|
|||||||
$tableIndexes = $this->_sm->listTableIndexes('test_create_index');
|
$tableIndexes = $this->_sm->listTableIndexes('test_create_index');
|
||||||
$this->assertEquals('test', $tableIndexes[0]['name']);
|
$this->assertEquals('test', $tableIndexes[0]['name']);
|
||||||
$this->assertEquals(true, $tableIndexes[0]['unique']);
|
$this->assertEquals(true, $tableIndexes[0]['unique']);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Exception
|
* @expectedException \Exception
|
||||||
|
Loading…
x
Reference in New Issue
Block a user