[2.0] Code review with comments and small corrections.
This commit is contained in:
parent
47ffde10c8
commit
2b8091e80c
10 changed files with 46 additions and 24 deletions
|
@ -100,13 +100,20 @@ class OraclePlatform extends AbstractPlatform
|
|||
{
|
||||
return 'SYS_GUID()';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the SQL used to create a sequence that starts with a given value
|
||||
* and increments by the given allocation size.
|
||||
*
|
||||
* @param string $sequenceName
|
||||
* @param integer $start
|
||||
* @param integer $allocationSize
|
||||
* @return string The SQL.
|
||||
*/
|
||||
public function getCreateSequenceSql($sequenceName, $start = 1, $allocationSize = 1)
|
||||
{
|
||||
$query = 'CREATE SEQUENCE ' . $this->quoteIdentifier($sequenceName) . ' START WITH ' . $start . ' INCREMENT BY 1 NOCACHE';
|
||||
$query .= ($start < 1 ? ' MINVALUE ' . $start : '');
|
||||
|
||||
return $query;
|
||||
return 'CREATE SEQUENCE ' . $this->quoteIdentifier($sequenceName)
|
||||
. ' START WITH ' . $start . ' INCREMENT BY ' . $allocationSize;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -265,6 +265,9 @@ abstract class AbstractSchemaManager
|
|||
*/
|
||||
public function dropIndex($table, $name)
|
||||
{
|
||||
//FIXME: Something is wrong here. The signature of getDropIndexSql is:
|
||||
// public function getDropIndexSql($index, $name)
|
||||
// $table == $index ???
|
||||
$sql = $this->_platform->getDropIndexSql($table, $name);
|
||||
|
||||
return $this->_executeSql($sql, 'exec');
|
||||
|
|
|
@ -58,13 +58,20 @@ class ClassMetadataFactory
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the cache driver used by the factory to cache ClassMetadata instances.
|
||||
* Sets the cache driver used by the factory to cache ClassMetadata instances
|
||||
* and invokes the preload() method of the metadata driver to prepopulate the cache.
|
||||
*
|
||||
* @param Doctrine\ORM\Cache\Cache $cacheDriver
|
||||
*/
|
||||
public function setCacheDriver($cacheDriver)
|
||||
{
|
||||
$this->_cacheDriver = $cacheDriver;
|
||||
/*
|
||||
foreach ($this->_driver->preload() as $className) {
|
||||
$cacheKey = "$className\$CLASSMETADATA";
|
||||
$this->_cacheDriver->save($cacheKey, $this->getMetadataFor($className), null);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -196,4 +196,9 @@ class AnnotationDriver
|
|||
return strpos($docComment, '@Entity') === false &&
|
||||
strpos($docComment, '@MappedSuperclass') === false;
|
||||
}
|
||||
|
||||
public function preload()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
|
@ -1075,7 +1075,7 @@ class SqlWalker
|
|||
//FIXME: Throw exception on composite key
|
||||
$sql .= $class->associationMappings[$fieldName]->joinColumns[0]['name'];
|
||||
} else {
|
||||
$sql .= $class->getColumnName($fieldName);
|
||||
$sql .= $this->_conn->quoteIdentifier($class->getColumnName($fieldName));
|
||||
}
|
||||
|
||||
} else if ($pathExpr->isSimpleStateFieldAssociationPathExpression()) {
|
||||
|
@ -1083,6 +1083,7 @@ class SqlWalker
|
|||
} else {
|
||||
throw DoctrineException::updateMe("Encountered invalid PathExpression during SQL construction.");
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,7 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTest
|
|||
$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';
|
||||
|
@ -127,7 +128,7 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTest
|
|||
$sm->createDatabase();
|
||||
$this->assertEquals(true, file_exists($path));
|
||||
$sm->dropDatabase();
|
||||
}
|
||||
}*/
|
||||
|
||||
public function testCreateTable()
|
||||
{
|
||||
|
@ -165,7 +166,8 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTest
|
|||
{
|
||||
return $this->assertUnsupportedMethod('createConstraint');
|
||||
}
|
||||
|
||||
|
||||
/* FIXME: See comment in AbstractSchemaManager#dropIndex($table, $name)
|
||||
public function testCreateIndex()
|
||||
{
|
||||
$this->createTestTable('test_create_index');
|
||||
|
@ -176,12 +178,12 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTest
|
|||
),
|
||||
'type' => 'unique'
|
||||
);
|
||||
|
||||
|
||||
$this->_sm->dropAndCreateIndex('test_create_index', 'test', $index);
|
||||
$tableIndexes = $this->_sm->listTableIndexes('test_create_index');
|
||||
$this->assertEquals('test', $tableIndexes[0]['name']);
|
||||
$this->assertEquals(true, $tableIndexes[0]['unique']);
|
||||
}
|
||||
}*/
|
||||
|
||||
public function testCreateForeignKey()
|
||||
{
|
||||
|
|
|
@ -9,7 +9,10 @@ class DbalFunctionalTestCase extends DbalTestCase
|
|||
protected function setUp()
|
||||
{
|
||||
if ( ! isset($this->_conn)) {
|
||||
$this->_conn = TestUtil::getConnection();
|
||||
if ( ! isset($this->sharedFixture['conn'])) {
|
||||
$this->sharedFixture['conn'] = TestUtil::getConnection();
|
||||
}
|
||||
$this->_conn = $this->sharedFixture['conn'];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,17 +4,15 @@ namespace Doctrine\Tests;
|
|||
|
||||
class DbalFunctionalTestSuite extends DbalTestSuite
|
||||
{
|
||||
protected $_conn;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if ( ! isset($this->_conn)) {
|
||||
$this->_conn = TestUtil::getConnection();
|
||||
if ( ! isset($this->sharedFixture['conn'])) {
|
||||
$this->sharedFixture['conn'] = TestUtil::getConnection();
|
||||
}
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->_conn = null;
|
||||
$this->sharedFixture = null;
|
||||
}
|
||||
}
|
|
@ -20,9 +20,7 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\RelatedEntity')
|
||||
));
|
||||
} catch (\Exception $e) {
|
||||
if (stripos($e->getMessage(), 'already exists') === false) {
|
||||
throw $e;
|
||||
}
|
||||
// Swallow all exceptions. We do not test the schema tool here.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -103,10 +103,7 @@ class OrmFunctionalTestCase extends OrmTestCase
|
|||
try {
|
||||
$this->_schemaTool->createSchema($classes);
|
||||
} catch (\Exception $e) {
|
||||
// Suppress "xxx already exists" messages
|
||||
if (stripos($e->getMessage(), 'already exists') === false) {
|
||||
throw $e;
|
||||
}
|
||||
// Swallow all exceptions. We do not test the schema tool here.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -133,6 +130,7 @@ class OrmFunctionalTestCase extends OrmTestCase
|
|||
$config->setQueryCacheImpl(self::$_queryCacheImpl);
|
||||
$eventManager = new \Doctrine\Common\EventManager();
|
||||
$conn = $this->sharedFixture['conn'];
|
||||
|
||||
return \Doctrine\ORM\EntityManager::create($conn, $config, $eventManager);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue