diff --git a/lib/Doctrine/DBAL/Schema/AbstractAsset.php b/lib/Doctrine/DBAL/Schema/AbstractAsset.php index 1e2f3da3b..14a3bf932 100644 --- a/lib/Doctrine/DBAL/Schema/AbstractAsset.php +++ b/lib/Doctrine/DBAL/Schema/AbstractAsset.php @@ -44,11 +44,6 @@ abstract class AbstractAsset */ protected $_name; - /** - * @var int - */ - protected $_caseMode = self::CASE_KEEP; - /** * Set name of this asset * @@ -66,7 +61,7 @@ abstract class AbstractAsset */ public function getName() { - return $this->_foldIdentifier($this->_name); + return $this->_name; } /** @@ -91,47 +86,4 @@ abstract class AbstractAsset $parts[] = $postfix; return trim(implode("_", $parts), '_'); } - - /** - * Set the case mode of this asset. - * - * @param string $caseMode - * @return void - */ - public function setCaseMode($caseMode) - { - if (!in_array($caseMode, array(self::CASE_KEEP, self::CASE_LOWER, self::CASE_UPPER))) { - throw SchemaException::invalidCaseModeGiven($caseMode); - } - $this->_caseMode = $caseMode; - } - - /** - * Fold the case of the identifier based on the CASE_* constants. - * - * This has never to be applied on write operation, only on read! This ensures that you can change - * the case at any point. For the keys of arrays however we always store them in lower-case which - * makes it easy to access them. This affects the maps in Schema and Table instances. - * - * @param string $identifier - * @return string - */ - protected function _foldIdentifier($identifier) - { - if ($this->_caseMode == self::CASE_UPPER) { - return strtoupper($identifier); - } else if ($this->_caseMode == self::CASE_LOWER) { - return strtolower($identifier); - } - return $identifier; - } - - /** - * @param array $identifiers - * @return array - */ - protected function _foldIdentifiers($identifiers) - { - return array_map(array($this, '_foldIdentifier'), $identifiers); - } } \ No newline at end of file diff --git a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php index 71df5231e..884728318 100644 --- a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php @@ -55,11 +55,6 @@ abstract class AbstractSchemaManager */ protected $_platform; - /** - * @var string - */ - protected $_caseMode = AbstractAsset::CASE_KEEP; - /** * Constructor. Accepts the Connection instance to manage the schema for * @@ -71,22 +66,6 @@ abstract class AbstractSchemaManager $this->_platform = $this->_conn->getDatabasePlatform(); } - /** - * @param string $caseMode - */ - public function setCaseMode($caseMode) - { - $this->_caseMode = $caseMode; - } - - /** - * @return string - */ - public function getCaseMode() - { - return $this->_caseMode; - } - /** * Return associated platform. * @@ -288,9 +267,7 @@ abstract class AbstractSchemaManager } } - $table = new Table($tableName, $columns, $indexes, $foreignKeys, $idGeneratorType, array()); - $table->setCaseMode($this->_caseMode); - $tables[] = $table; + $tables[] = new Table($tableName, $columns, $indexes, $foreignKeys, $idGeneratorType, array()); } return $tables; @@ -928,7 +905,6 @@ abstract class AbstractSchemaManager $indexes = array(); foreach($result AS $indexKey => $data) { $indexes[$indexKey] = new Index($data['name'], $data['columns'], $data['unique'], $data['primary']); - $indexes[$indexKey]->setCaseMode($this->_caseMode); } return $indexes; @@ -1018,9 +994,6 @@ abstract class AbstractSchemaManager } $tables = $this->listTables(); - $schema = new Schema($tables, $sequences); - $schema->setCaseMode($this->_caseMode); - - return $schema; + return new Schema($tables, $sequences); } } \ No newline at end of file diff --git a/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php b/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php index 46d25b116..74c1e4d8c 100644 --- a/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php +++ b/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php @@ -72,12 +72,12 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint */ public function getLocalColumns() { - return $this->_foldIdentifiers($this->_localColumnNames); + return $this->_localColumnNames; } public function getColumns() { - return $this->_foldIdentifiers($this->_localColumnNames); + return $this->_localColumnNames; } /** @@ -85,7 +85,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint */ public function getForeignTableName() { - return $this->_foldIdentifier($this->_foreignTableName); + return $this->_foreignTableName; } /** @@ -93,7 +93,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint */ public function getForeignColumns() { - return $this->_foldIdentifiers($this->_foreignColumnNames); + return $this->_foreignColumnNames; } public function hasOption($name) diff --git a/lib/Doctrine/DBAL/Schema/Index.php b/lib/Doctrine/DBAL/Schema/Index.php index 68f0aaa14..10f9aa810 100644 --- a/lib/Doctrine/DBAL/Schema/Index.php +++ b/lib/Doctrine/DBAL/Schema/Index.php @@ -76,7 +76,7 @@ class Index extends AbstractAsset implements Constraint */ public function getColumns() { - return $this->_foldIdentifiers($this->_columns); + return $this->_columns; } /** @@ -102,7 +102,6 @@ class Index extends AbstractAsset implements Constraint */ public function hasColumnAtPosition($columnName, $pos=0) { - $columnName = $this->_foldIdentifier($columnName); return \array_search($columnName, $this->getColumns()) === $pos; } } \ No newline at end of file diff --git a/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php index 6c160888a..e52cd1260 100644 --- a/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php @@ -259,23 +259,19 @@ class MySqlSchemaManager extends AbstractSchemaManager $options['precision'] = $precision; } - $column = new Column($tableColumn['Field'], \Doctrine\DBAL\Types\Type::getType($type), $options); - $column->setCaseMode($this->getCaseMode()); - return $column; + return new Column($tableColumn['Field'], \Doctrine\DBAL\Types\Type::getType($type), $options); } public function _getPortableTableForeignKeyDefinition($tableForeignKey) { $tableForeignKey = array_change_key_case($tableForeignKey, CASE_LOWER); - $fk = new ForeignKeyConstraint( + return new ForeignKeyConstraint( (array)$tableForeignKey['column_name'], $tableForeignKey['referenced_table_name'], (array)$tableForeignKey['referenced_column_name'], $tableForeignKey['constraint_name'], array() ); - $fk->setCaseMode($this->getCaseMode()); - return $fk; } } \ No newline at end of file diff --git a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php index d5e2e9344..f5d0dca9c 100644 --- a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php @@ -189,9 +189,7 @@ class OracleSchemaManager extends AbstractSchemaManager 'platformDetails' => array(), ); - $column = new Column($tableColumn['column_name'], \Doctrine\DBAL\Types\Type::getType($type), $options); - $column->setCaseMode($this->getCaseMode()); - return $column; + return new Column($tableColumn['column_name'], \Doctrine\DBAL\Types\Type::getType($type), $options); } protected function _getPortableTableForeignKeysList($tableForeignKeys) @@ -214,13 +212,11 @@ class OracleSchemaManager extends AbstractSchemaManager $result = array(); foreach($list AS $constraint) { - $fk = new ForeignKeyConstraint( + $result[] = new ForeignKeyConstraint( array_values($constraint['local']), $constraint['foreignTable'], array_values($constraint['foreign']), $constraint['name'], array('onDelete' => $constraint['onDelete']) ); - $fk->setCaseMode($this->getCaseMode()); - $result[] = $fk; } return $result; @@ -229,9 +225,7 @@ class OracleSchemaManager extends AbstractSchemaManager protected function _getPortableSequenceDefinition($sequence) { $sequence = \array_change_key_case($sequence, CASE_LOWER); - $sequence = new Sequence($sequence['sequence_name'], $sequence['increment_by'], $sequence['min_value']); - $sequence->setCaseMode($this->getCaseMode()); - return $sequence; + return new Sequence($sequence['sequence_name'], $sequence['increment_by'], $sequence['min_value']); } protected function _getPortableTableConstraintDefinition($tableConstraint) diff --git a/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php index 9eb761b7a..3c3bbc68d 100644 --- a/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php @@ -51,12 +51,10 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager $foreignTable = $values[2]; } - $fk = new ForeignKeyConstraint( + return new ForeignKeyConstraint( $localColumns, $foreignTable, $foreignColumns, $tableForeignKey['conname'], array('onUpdate' => $onUpdate, 'onDelete' => $onDelete) ); - $fk->setCaseMode($this->getCaseMode()); - return $fk; } public function dropDatabase($database) @@ -156,9 +154,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager protected function _getPortableSequenceDefinition($sequence) { $data = $this->_conn->fetchAll('SELECT min_value, increment_by FROM '.$sequence['relname']); - $sequence = new Sequence($sequence['relname'], $data[0]['increment_by'], $data[0]['min_value']); - $sequence->setCaseMode($this->getCaseMode()); - return $sequence; + return new Sequence($sequence['relname'], $data[0]['increment_by'], $data[0]['min_value']); } protected function _getPortableTableConstraintDefinition($tableConstraint) @@ -334,8 +330,6 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ), ); - $column = new Column($tableColumn['field'], \Doctrine\DBAL\Types\Type::getType($type), $options); - $column->setCaseMode($this->getCaseMode()); - return $column; + return new Column($tableColumn['field'], \Doctrine\DBAL\Types\Type::getType($type), $options); } } \ No newline at end of file diff --git a/lib/Doctrine/DBAL/Schema/Schema.php b/lib/Doctrine/DBAL/Schema/Schema.php index d7a19403f..e1b90a3ff 100644 --- a/lib/Doctrine/DBAL/Schema/Schema.php +++ b/lib/Doctrine/DBAL/Schema/Schema.php @@ -65,8 +65,6 @@ class Schema extends AbstractAsset */ protected function _addTable(Table $table) { - $table->setCaseMode($this->_caseMode); - $tableName = strtolower($table->getName()); if(isset($this->_tables[$tableName])) { throw SchemaException::tableAlreadyExists($tableName); @@ -80,8 +78,6 @@ class Schema extends AbstractAsset */ protected function _addSequence(Sequence $sequence) { - $sequence->setCaseMode($this->_caseMode); - $seqName = strtolower($sequence->getName()); if (isset($this->_sequences[$seqName])) { throw SchemaException::sequenceAlreadyExists($seqName); diff --git a/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php b/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php index 6865d4bb9..ca76a68f6 100644 --- a/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php @@ -255,8 +255,6 @@ class SqliteSchemaManager extends AbstractSchemaManager ), ); - $column = new Column($tableColumn['name'], \Doctrine\DBAL\Types\Type::getType($type), $options); - $column->setCaseMode($this->getCaseMode()); - return $column; + return new Column($tableColumn['name'], \Doctrine\DBAL\Types\Type::getType($type), $options); } } \ No newline at end of file diff --git a/lib/Doctrine/DBAL/Schema/Table.php b/lib/Doctrine/DBAL/Schema/Table.php index 165f071ab..831f37866 100644 --- a/lib/Doctrine/DBAL/Schema/Table.php +++ b/lib/Doctrine/DBAL/Schema/Table.php @@ -337,8 +337,6 @@ class Table extends AbstractAsset */ protected function _addColumn(Column $column) { - $column->setCaseMode($this->_caseMode); - $columnName = $column->getName(); $columnName = strtolower($columnName); @@ -357,8 +355,6 @@ class Table extends AbstractAsset */ protected function _addIndex(Index $index) { - $index->setCaseMode($this->_caseMode); - $indexName = $index->getName(); $indexName = strtolower($indexName); @@ -379,8 +375,6 @@ class Table extends AbstractAsset */ protected function _addForeignKeyConstraint(ForeignKeyConstraint $constraint) { - $constraint->setCaseMode($this->_caseMode); - if(strlen($constraint->getName())) { $name = $constraint->getName(); } else { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php index c4b39d32a..c6ed9ce4d 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php @@ -95,12 +95,8 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest $columns = $this->_sm->listTableColumns('list_table_columns'); - foreach ($columns AS $column) { - $column->setCaseMode("lower"); - } - $this->assertArrayHasKey('id', $columns); - $this->assertEquals('id', $columns['id']->getname()); + $this->assertEquals('id', strtolower($columns['id']->getname())); $this->assertType('Doctrine\DBAL\Types\IntegerType', $columns['id']->gettype()); $this->assertEquals(false, $columns['id']->getunsigned()); $this->assertEquals(true, $columns['id']->getnotnull()); @@ -108,7 +104,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest $this->assertType('array', $columns['id']->getPlatformOptions()); $this->assertArrayHasKey('test', $columns); - $this->assertEquals('test', $columns['test']->getname()); + $this->assertEquals('test', strtolower($columns['test']->getname())); $this->assertType('Doctrine\DBAL\Types\StringType', $columns['test']->gettype()); $this->assertEquals(255, $columns['test']->getlength()); $this->assertEquals(false, $columns['test']->getfixed()); @@ -116,7 +112,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest $this->assertEquals(null, $columns['test']->getdefault()); $this->assertType('array', $columns['test']->getPlatformOptions()); - $this->assertEquals('foo', ($columns['foo']->getname())); + $this->assertEquals('foo', strtolower($columns['foo']->getname())); $this->assertType('Doctrine\DBAL\Types\TextType', $columns['foo']->gettype()); $this->assertEquals(null, $columns['foo']->getlength()); $this->assertEquals(false, $columns['foo']->getunsigned()); @@ -125,30 +121,30 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest $this->assertEquals(null, $columns['foo']->getdefault()); $this->assertType('array', $columns['foo']->getPlatformOptions()); - $this->assertEquals('bar', ($columns['bar']->getname())); + $this->assertEquals('bar', strtolower($columns['bar']->getname())); $this->assertType('Doctrine\DBAL\Types\DecimalType', $columns['bar']->gettype()); $this->assertEquals(null, $columns['bar']->getlength()); - $this->assertEquals(10, $columns['bar']->getprecision()); - $this->assertEquals(4, $columns['bar']->getscale()); + $this->assertEquals(10, $columns['bar']->getprecision()); + $this->assertEquals(4, $columns['bar']->getscale()); $this->assertEquals(false, $columns['bar']->getunsigned()); $this->assertEquals(false, $columns['bar']->getfixed()); - $this->assertEquals(false, $columns['bar']->getnotnull()); + $this->assertEquals(false, $columns['bar']->getnotnull()); $this->assertEquals(null, $columns['bar']->getdefault()); $this->assertType('array', $columns['bar']->getPlatformOptions()); - $this->assertEquals('baz1', ($columns['baz1']->getname())); + $this->assertEquals('baz1', strtolower($columns['baz1']->getname())); $this->assertType('Doctrine\DBAL\Types\DateTimeType', $columns['baz1']->gettype()); $this->assertEquals(true, $columns['baz1']->getnotnull()); $this->assertEquals(null, $columns['baz1']->getdefault()); $this->assertType('array', $columns['baz1']->getPlatformOptions()); - $this->assertEquals('baz2', ($columns['baz2']->getname())); + $this->assertEquals('baz2', strtolower($columns['baz2']->getname())); $this->assertContains($columns['baz2']->gettype()->getName(), array('Time', 'Date', 'DateTime')); $this->assertEquals(true, $columns['baz2']->getnotnull()); $this->assertEquals(null, $columns['baz2']->getdefault()); $this->assertType('array', $columns['baz2']->getPlatformOptions()); - $this->assertEquals('baz3', ($columns['baz3']->getname())); + $this->assertEquals('baz3', strtolower($columns['baz3']->getname())); $this->assertContains($columns['baz2']->gettype()->getName(), array('Time', 'Date', 'DateTime')); $this->assertEquals(true, $columns['baz3']->getnotnull()); $this->assertEquals(null, $columns['baz3']->getdefault()); @@ -192,7 +188,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest $tableIndexes = $this->_sm->listTableIndexes('test_create_index'); $this->assertType('array', $tableIndexes); - $this->assertEquals('test', $tableIndexes['test']->getName()); + $this->assertEquals('test', strtolower($tableIndexes['test']->getName())); $this->assertEquals(array('test'), array_map('strtolower', $tableIndexes['test']->getColumns())); $this->assertTrue($tableIndexes['test']->isUnique()); $this->assertFalse($tableIndexes['test']->isPrimary()); @@ -217,10 +213,10 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest $this->assertEquals(1, count($fkConstraints)); $fkConstraint = current($fkConstraints); - $fkConstraint->setCaseMode("lower"); - $this->assertEquals('test_foreign', $fkConstraint->getForeignTableName()); - $this->assertEquals(array('foreign_key_test'), $fkConstraint->getColumns()); - $this->assertEquals(array('id'), $fkConstraint->getForeignColumns()); + $this->assertType('\Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkConstraint); + $this->assertEquals('test_foreign', strtolower($fkConstraint->getForeignTableName())); + $this->assertEquals(array('foreign_key_test'), array_map('strtolower', $fkConstraint->getColumns())); + $this->assertEquals(array('id'), array_map('strtolower', $fkConstraint->getForeignColumns())); } public function testListForeignKeys() @@ -240,15 +236,11 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest $fkeys = $this->_sm->listTableForeignKeys('test_create_fk1'); - foreach ($fkeys AS $fkey) { - $fkey->setCaseMode("lower"); - } - $this->assertEquals(1, count($fkeys)); $this->assertType('Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkeys[0]); - $this->assertEquals(array('foreign_key_test'), array_map('strtolower', $fkeys[0]->getLocalColumns())); - $this->assertEquals(array('id'), array_map('strtolower', $fkeys[0]->getForeignColumns())); - $this->assertEquals('test_create_fk2', ($fkeys[0]->getForeignTableName())); + $this->assertEquals(array('foreign_key_test'), array_map('strtolower', $fkeys[0]->getLocalColumns())); + $this->assertEquals(array('id'), array_map('strtolower', $fkeys[0]->getForeignColumns())); + $this->assertEquals('test_create_fk2', strtolower($fkeys[0]->getForeignTableName())); if($fkeys[0]->hasOption('onUpdate')) { $this->assertEquals('CASCADE', $fkeys[0]->getOption('onUpdate')); diff --git a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php index 57aa0cd75..166697030 100644 --- a/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/DatabaseDriverTest.php @@ -18,7 +18,6 @@ class DatabaseDriverTest extends \Doctrine\Tests\OrmFunctionalTestCase parent::setUp(); $this->_sm = $this->_em->getConnection()->getSchemaManager(); - $this->_sm->setCaseMode("lower"); } public function testCreateSimpleYamlFromDatabase()