Commit ba61dd3d authored by Steve Müller's avatar Steve Müller

Merge pull request #553 from deeky666/DBAL-843

[DBAL-843] Fix reverse engineering LOB type column types in MySQL
parents 5cbe3ce8 829eb1c8
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
namespace Doctrine\DBAL\Schema; namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
/** /**
...@@ -146,16 +147,30 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -146,16 +147,30 @@ class MySqlSchemaManager extends AbstractSchemaManager
$length = null; $length = null;
} }
break; break;
case 'tinytext':
$length = MySqlPlatform::LENGTH_LIMIT_TINYTEXT;
break;
case 'text':
$length = MySqlPlatform::LENGTH_LIMIT_TEXT;
break;
case 'mediumtext':
$length = MySqlPlatform::LENGTH_LIMIT_MEDIUMTEXT;
break;
case 'tinyblob':
$length = MySqlPlatform::LENGTH_LIMIT_TINYBLOB;
break;
case 'blob':
$length = MySqlPlatform::LENGTH_LIMIT_BLOB;
break;
case 'mediumblob':
$length = MySqlPlatform::LENGTH_LIMIT_MEDIUMBLOB;
break;
case 'tinyint': case 'tinyint':
case 'smallint': case 'smallint':
case 'mediumint': case 'mediumint':
case 'int': case 'int':
case 'integer': case 'integer':
case 'bigint': case 'bigint':
case 'tinyblob':
case 'mediumblob':
case 'longblob':
case 'blob':
case 'year': case 'year':
$length = null; $length = null;
break; break;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Functional\Schema; namespace Doctrine\Tests\DBAL\Functional\Schema;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\Comparator; use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
...@@ -199,4 +200,63 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -199,4 +200,63 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this->assertEquals('latin1_swedish_ci', $columns['foo']->getPlatformOption('collation')); $this->assertEquals('latin1_swedish_ci', $columns['foo']->getPlatformOption('collation'));
$this->assertEquals('utf8_general_ci', $columns['bar']->getPlatformOption('collation')); $this->assertEquals('utf8_general_ci', $columns['bar']->getPlatformOption('collation'));
} }
/**
* @group DBAL-843
*/
public function testListLobTypeColumns()
{
$tableName = 'lob_type_columns';
$table = new Table($tableName);
$table->addColumn('col_tinytext', 'text', array('length' => MySqlPlatform::LENGTH_LIMIT_TINYTEXT));
$table->addColumn('col_text', 'text', array('length' => MySqlPlatform::LENGTH_LIMIT_TEXT));
$table->addColumn('col_mediumtext', 'text', array('length' => MySqlPlatform::LENGTH_LIMIT_MEDIUMTEXT));
$table->addColumn('col_longtext', 'text');
$table->addColumn('col_tinyblob', 'text', array('length' => MySqlPlatform::LENGTH_LIMIT_TINYBLOB));
$table->addColumn('col_blob', 'blob', array('length' => MySqlPlatform::LENGTH_LIMIT_BLOB));
$table->addColumn('col_mediumblob', 'blob', array('length' => MySqlPlatform::LENGTH_LIMIT_MEDIUMBLOB));
$table->addColumn('col_longblob', 'blob');
$this->_sm->dropAndCreateTable($table);
$platform = $this->_sm->getDatabasePlatform();
$offlineColumns = $table->getColumns();
$onlineColumns = $this->_sm->listTableColumns($tableName);
$this->assertSame(
$platform->getClobTypeDeclarationSQL($offlineColumns['col_tinytext']->toArray()),
$platform->getClobTypeDeclarationSQL($onlineColumns['col_tinytext']->toArray())
);
$this->assertSame(
$platform->getClobTypeDeclarationSQL($offlineColumns['col_text']->toArray()),
$platform->getClobTypeDeclarationSQL($onlineColumns['col_text']->toArray())
);
$this->assertSame(
$platform->getClobTypeDeclarationSQL($offlineColumns['col_mediumtext']->toArray()),
$platform->getClobTypeDeclarationSQL($onlineColumns['col_mediumtext']->toArray())
);
$this->assertSame(
$platform->getClobTypeDeclarationSQL($offlineColumns['col_longtext']->toArray()),
$platform->getClobTypeDeclarationSQL($onlineColumns['col_longtext']->toArray())
);
$this->assertSame(
$platform->getBlobTypeDeclarationSQL($offlineColumns['col_tinyblob']->toArray()),
$platform->getBlobTypeDeclarationSQL($onlineColumns['col_tinyblob']->toArray())
);
$this->assertSame(
$platform->getBlobTypeDeclarationSQL($offlineColumns['col_blob']->toArray()),
$platform->getBlobTypeDeclarationSQL($onlineColumns['col_blob']->toArray())
);
$this->assertSame(
$platform->getBlobTypeDeclarationSQL($offlineColumns['col_mediumblob']->toArray()),
$platform->getBlobTypeDeclarationSQL($onlineColumns['col_mediumblob']->toArray())
);
$this->assertSame(
$platform->getBlobTypeDeclarationSQL($offlineColumns['col_longblob']->toArray()),
$platform->getBlobTypeDeclarationSQL($onlineColumns['col_longblob']->toArray())
);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment