1
0
mirror of synced 2024-12-13 06:46:03 +03:00

[2.0] DDC-313 - Removed abstracted trigger support, list functions, list users and the platform specific code to generate the queries for this stuff.

This commit is contained in:
beberlei 2010-02-11 13:06:14 +00:00
parent 86c12a07e5
commit 5b43f72e27
10 changed files with 4 additions and 225 deletions

View File

@ -1449,16 +1449,6 @@ abstract class AbstractPlatform
throw DBALException::notSupported(__METHOD__);
}
public function getListFunctionsSql()
{
throw DBALException::notSupported(__METHOD__);
}
public function getListTriggersSql($table = null)
{
throw DBALException::notSupported(__METHOD__);
}
public function getListSequencesSql($database)
{
throw DBALException::notSupported(__METHOD__);

View File

@ -154,20 +154,6 @@ class MySqlPlatform extends AbstractPlatform
return 'SHOW DATABASES';
}
public function getListFunctionsSql()
{
return 'SELECT SPECIFIC_NAME FROM information_schema.ROUTINES';
}
public function getListSequencesSql($database)
{
$query = 'SHOW TABLES';
if ( ! is_null($database)) {
$query .= ' FROM ' . $database;
}
return $query;
}
public function getListTableConstraintsSql($table)
{
return 'SHOW INDEX FROM ' . $table;
@ -178,20 +164,6 @@ class MySqlPlatform extends AbstractPlatform
return 'SHOW INDEX FROM ' . $table;
}
public function getListUsersSql()
{
return "SELECT * FROM mysql.user WHERE user != '' GROUP BY user";
}
public function getListTriggersSql($table = null)
{
$sql = "SELECT TRIGGER_NAME FROM information_schema.TRIGGERS";
if($table !== null) {
$sql .= " WHERE EVENT_OBJECT_TABLE = '".$table."'";
}
return $sql;
}
public function getListViewsSql($database)
{
return "SELECT * FROM information_schema.VIEWS WHERE TABLE_SCHEMA = '".$database."'";

View File

@ -258,11 +258,6 @@ class OraclePlatform extends AbstractPlatform
return 'SELECT username FROM all_users';
}
public function getListFunctionsSql()
{
return "SELECT name FROM sys.user_source WHERE line = 1 AND type = 'FUNCTION'";
}
public function getListSequencesSql($database)
{
return "SELECT sequence_name, min_value, increment_by FROM sys.all_sequences ".
@ -327,11 +322,6 @@ class OraclePlatform extends AbstractPlatform
return 'SELECT * FROM sys.user_tables';
}
public function getListUsersSql()
{
return 'SELECT * FROM all_users';
}
public function getListViewsSql($database)
{
return 'SELECT view_name, text FROM sys.user_views';

View File

@ -273,21 +273,6 @@ class PostgreSqlPlatform extends AbstractPlatform
return 'SELECT datname FROM pg_database';
}
public function getListFunctionsSql()
{
return "SELECT
proname
FROM
pg_proc pr, pg_type tp
WHERE
tp.oid = pr.prorettype
AND pr.proisagg = FALSE
AND tp.typname <> 'trigger'
AND pr.pronamespace IN
(SELECT oid FROM pg_namespace
WHERE nspname NOT LIKE 'pg_%' AND nspname != 'information_schema')";
}
public function getListSequencesSql($database)
{
return "SELECT
@ -322,25 +307,6 @@ class PostgreSqlPlatform extends AbstractPlatform
return 'SELECT viewname, definition FROM pg_views';
}
public function getListTriggersSql($table = null)
{
$sql = 'SELECT trg.tgname AS trigger_name
FROM pg_trigger trg,
pg_class tbl
WHERE trg.tgrelid = tbl.oid';
if ( ! is_null($table)) {
$sql .= " AND tbl.relname = " . $table;
}
return $sql;
}
public function getListUsersSql()
{
return 'SELECT usename, passwd FROM pg_user';
}
public function getListTableForeignKeysSql($table, $database = null)
{
return "SELECT r.conname, pg_catalog.pg_get_constraintdef(r.oid, true) as condef

View File

@ -102,8 +102,6 @@ abstract class AbstractSchemaManager
}
}
/* list*() Methods */
/**
* List the available databases for this connection
*
@ -118,40 +116,6 @@ abstract class AbstractSchemaManager
return $this->_getPortableDatabasesList($databases);
}
/**
* List the names of available functions for this connection
*
* @example array(
* 'functionA', 'functionB', 'procedureA',
* )
* @return array $functions
*/
public function listFunctions()
{
$sql = $this->_platform->getListFunctionsSql();
$functions = $this->_conn->fetchAll($sql);
return $this->_getPortableFunctionsList($functions);
}
/**
* List the names of available triggers for this connection
*
* @example array(
* 'triggerName1', 'triggerName2',
* );
* @return array $triggers
*/
public function listTriggers()
{
$sql = $this->_platform->getListTriggersSql();
$triggers = $this->_conn->fetchAll($sql);
return $this->_getPortableTriggersList($triggers);
}
/**
* List the available sequences for this connection
*
@ -262,20 +226,6 @@ abstract class AbstractSchemaManager
return new Table($tableName, $columns, $indexes, $foreignKeys, $idGeneratorType, array());
}
/**
* List the users this connection has
*
* @return array $users
*/
public function listUsers()
{
$sql = $this->_platform->getListUsersSql();
$users = $this->_conn->fetchAll($sql);
return $this->_getPortableUsersList($users);
}
/**
* List the views this connection has
*
@ -294,7 +244,7 @@ abstract class AbstractSchemaManager
* List the foreign keys for the given table
*
* @param string $table The name of the table
* @return array $tableForeignKeys
* @return ForeignKeyConstraint[]
*/
public function listTableForeignKeys($table, $database = null)
{

View File

@ -8,18 +8,5 @@ require_once __DIR__ . '/../../../TestInit.php';
class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
public function testListUsers()
{
$users = $this->_sm->listUsers();
$this->assertEquals(true, is_array($users));
$params = $this->_conn->getParams();
$testUser = $params['user'];
$found = false;
foreach ($users as $user) {
if ($user['user'] == $testUser) {
$found = true;
}
}
$this->assertEquals(true, $found);
}
}

View File

@ -24,29 +24,6 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
$conn->executeUpdate($query);
}
/**
* @expectedException \Exception
*/
public function testListTriggers()
{
$this->_sm->listTriggers();
}
public function testListUsers()
{
$users = $this->_sm->listUsers();
$this->assertEquals(true, is_array($users));
$params = $this->_conn->getParams();
$testUser = strtoupper($params['user']);
$found = false;
foreach ($users as $user) {
if ($user['user'] == $testUser) {
$found = true;
}
}
$this->assertEquals(true, $found);
}
public function testRenameTable()
{
$this->_sm->tryMethod('DropTable', 'list_tables_test');

View File

@ -8,18 +8,5 @@ require_once __DIR__ . '/../../../TestInit.php';
class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
public function testListUsers()
{
$users = $this->_sm->listUsers();
$this->assertEquals(true, is_array($users));
$params = $this->_conn->getParams();
$testUser = $params['user'];
$found = false;
foreach ($users as $user) {
if ($user['user'] == $testUser) {
$found = true;
}
}
$this->assertEquals(true, $found);
}
}

View File

@ -57,20 +57,6 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$this->assertEquals(10, $foundSequence->getInitialValue(), "Initial Value is expected to be 10.");
}
public function testListFunctions()
{
$funcs = $this->_sm->listFunctions();
$this->assertType('array', $funcs);
$this->assertTrue(count($funcs)>=0);
}
public function testListTriggers()
{
$triggers = $this->_sm->listTriggers();
$this->assertType('array', $triggers);
$this->assertTrue(count($triggers) >= 0);
}
public function testListDatabases()
{
$this->_sm->dropAndCreateDatabase('test_create_database');

View File

@ -18,32 +18,6 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this->_sm->listDatabases();
}
/**
* SQLITE does not support databases.
*
* @expectedException \Exception
*/
public function testListFunctions()
{
$this->_sm->listFunctions();
}
/**
* @expectedException \Exception
*/
public function testListTriggers()
{
$this->_sm->listTriggers();
}
/**
* @expectedException \Exception
*/
public function testListUsers()
{
$this->_sm->listUsers();
}
public function testCreateAndDropDatabase()
{
$path = dirname(__FILE__).'/test_create_and_drop_sqlite_database.sqlite';