[DBAL-232] Custom commented column type removal causes unknown column type exception Created: 06/Mar/12  Updated: 09/Mar/12

Status: Open
Project: Doctrine DBAL
Component/s: Schema Managers
Affects Version/s: 2.2.1
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Major
Reporter: Aigars Gedroics Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Problem happens when initially, as example, there was commented type "foo" registered and used:

Doctrine\DBAL\Types\Type::addType('foo', 'FooType');
$em->getConnection()
    ->getDatabasePlatform()
    ->markDoctrineTypeCommented(Doctrine\DBAL\Types\Type::getType('foo'));

When the type usage and declaration is removed, the database schema upgrade fails.
This is because DBAL reads the comment from the database and tries to find the type 'foo'.

I suggest ignoring the database column comment and stick to the standard type recognition in case the type is not declared.



 Comments   
Comment by Aigars Gedroics [ 09/Mar/12 ]

Trivial solution would be:

--- a/Doctrine/DBAL/Schema/AbstractSchemaManager.php
+++ b/Doctrine/DBAL/Schema/AbstractSchemaManager.php
@@ -878,7 +878,9 @@ abstract class AbstractSchemaManager
     public function extractDoctrineTypeFromComment($comment, $currentType)
     {
         if (preg_match("(\(DC2Type:([a-zA-Z0-9]+)\))", $comment, $match)) {
-            $currentType = $match[1];
+                       if (Types\Type::hasType($match[1])) {
+                               $currentType = $match[1];
+                       }
         }
         return $currentType;
     }
Generated at Fri May 24 03:58:38 UTC 2013 using JIRA 5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5.