Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-232

Custom commented column type removal causes unknown column type exception

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.2.1
    • Fix Version/s: None
    • Component/s: Schema Managers
    • Security Level: All
    • 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.

        Activity

        Aigars Gedroics created issue -
        Hide
        Aigars Gedroics added a comment -

        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;
             }
        
        Show
        Aigars Gedroics added a comment - 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; }
        Benjamin Eberlei made changes -
        Field Original Value New Value
        Workflow jira [ 13499 ] jira-feedback2 [ 17599 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 17599 ] jira-feedback3 [ 19953 ]
        Hide
        Steve Müller added a comment -

        Proposed solution applied in PR:

        https://github.com/doctrine/dbal/pull/406

        Show
        Steve Müller added a comment - Proposed solution applied in PR: https://github.com/doctrine/dbal/pull/406
        Hide
        Doctrine Bot added a comment -

        A related Github Pull-Request [GH-406] was closed:
        https://github.com/doctrine/dbal/pull/406

        Show
        Doctrine Bot added a comment - A related Github Pull-Request [GH-406] was closed: https://github.com/doctrine/dbal/pull/406
        Hide
        Steve Müller added a comment -

        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.

        Show
        Steve Müller added a comment - 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.
        Steve Müller made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Won't Fix [ 2 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DBAL-232, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Aigars Gedroics
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: