Skip to content

Loading…

DBAL-232: Custom commented column type removal causes unknown column type exception #1408

Closed
doctrinebot opened this Issue · 5 comments

2 participants

@doctrinebot

Jira issue originally created by user gedrox:

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.

@doctrinebot

Comment created by gedrox:

Trivial solution would be:

--- a/Doctrine/DBAL/Schema/AbstractSchemaManager.php
<ins></ins><ins> b/Doctrine/DBAL/Schema/AbstractSchemaManager.php
@@ -878,7 </ins>878,9 @@ abstract class AbstractSchemaManager
     public function extractDoctrineTypeFromComment($comment, $currentType)
     {
         if (preg_match("(\(DC2Type:([a-zA-Z0-9]<ins>)\))", $comment, $match)) {
-            $currentType = $match[1];
</ins>                       if (Types\Type::hasType($match[1])) {
<ins>                               $currentType = $match[1];
</ins>                       }
         }
         return $currentType;
     }
@doctrinebot

Comment created by @deeky666:

Proposed solution applied in PR:

#406

@doctrinebot

Comment created by @doctrinebot:

A related Github Pull-Request [GH-406] was closed:
#406

@doctrinebot

Comment created by @deeky666:

As discussed with ocramius, it is not a good solution to silence this error during schema introspection. The problem has to be fixed by registering the missing types in the application or modifying the database schema manually by removing the column comment. This is what the current exception message suggest anyways.

@doctrinebot

Issue was closed with resolution "Won't Fix"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.