Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-6

MySQL BLOB datatypes throw DoctrineException::unknownColumnType() exception

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.4
    • Fix Version/s: 2.2
    • Component/s: Schema Managers
    • Labels:
      None
    • Environment:
      Windows 7 x64, PHP 5.3.1, MySQL 5.1.36 (pdo_mysql driver)

      Description

      MySQL BLOB datatype appears to be breaking ClassMetadataExporter. Very new to Doctrine so hopefully I've isolated this correctly.

      CREATE TABLE foo (
          id      BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
          bar   BLOB,
          PRIMARY KEY (id)
      ) ENGINE=InnoDB;
      
      // ... setup entitymanager ....
      
      $cme = new \Doctrine\ORM\Tools\Export\ClassMetadataExporter();
      $sm = $em->getConnection()->getSchemaManager();
      $cme->addMappingSource($sm, 'database');
      $metadatas = $cme->getMetadatasForMappingSources();
      $exporter = $cme->getExporter('annotation', '/path/to/annotations');
      $exporter->setMetadatas($metadatas);
      $exporter->export();
      
      php -f doctrine Orm:convert-mapping --from-database --to=annotation --dest C:\www\app\models
      
      Fatal error: Uncaught exception 'Doctrine\Common\DoctrineException' with message 'Unknown column type' in C:\www\app\lib\Doctrine\Common\DoctrineException.php:112
      
      Stack trace:
      #0 [internal function]: Doctrine\Common\DoctrineException::__callStatic('unknownColumnTy...', Array)
      #1 C:\www\app\lib\Doctrine\DBAL\Types\Type.php(125): Doctrine\Common\DoctrineException::unknownColumnType('blob')
      #2 C:\www\app\lib\Doctrine\DBAL\Schema\MySqlSchemaManager.php(262): Doctrine\DBAL\Types\Type::getType('blob')
      #3 C:\www\app\lib\Doctrine\DBAL\Schema\AbstractSchemaManager.php(802): Doctrine\DBAL\Schema\MySqlSchemaManager->_getPortableTableColumnDefinition(Array)
      #4 C:\www\app\lib\Doctrine\DBAL\Schema\AbstractSchemaManager.php(221): Doctrine\DBAL\Schema\AbstractSchemaManager->_getPortableTableColumnList(Array)
      #5 C:\www\app in C:\www\app\lib\Doctrine\Common\DoctrineException.php on line 112
      

        Issue Links

          Activity

          Hide
          Benjamin Eberlei added a comment -

          You did isolate it correctly, we haven't gotten around to support BLOBs yet, because they are very complex to handle across different database vendors.

          We probably should address this asap though for beta 2.

          Show
          Benjamin Eberlei added a comment - You did isolate it correctly, we haven't gotten around to support BLOBs yet, because they are very complex to handle across different database vendors. We probably should address this asap though for beta 2.
          Hide
          Roman S. Borschel added a comment -

          Unless I am missing something it should be easy to work around this by creating a custom type (that will, of course, be mysql-specific).

          Show
          Roman S. Borschel added a comment - Unless I am missing something it should be easy to work around this by creating a custom type (that will, of course, be mysql-specific).
          Hide
          Benjamin Eberlei added a comment -

          @Roman: I think the problem with custom types currently is that you cannot register them in Platform, giving you almost no chance to use custom types
          with SchemaTool

          Show
          Benjamin Eberlei added a comment - @Roman: I think the problem with custom types currently is that you cannot register them in Platform, giving you almost no chance to use custom types with SchemaTool
          Hide
          Christian Heinrich added a comment -

          @Benjamin: Where exactly is the problem? DBAL\Types\Type supports adding custom types...

          Show
          Christian Heinrich added a comment - @Benjamin: Where exactly is the problem? DBAL\Types\Type supports adding custom types...
          Hide
          Benjamin Eberlei added a comment -

          Mark as New Feature.

          Blobs are so fundamentally different even across different PDO drivers that we might not implement them in Core, there is no common denominator we can abstract completely.

          Show
          Benjamin Eberlei added a comment - Mark as New Feature. Blobs are so fundamentally different even across different PDO drivers that we might not implement them in Core, there is no common denominator we can abstract completely.
          Hide
          Oleg Anashkin added a comment -

          Please consider implementing this in Doctrine 2.1, my database uses blobs for storing some binary data therefore I can't use doctrine for schema updates anymore - it won't even product the migration sql script.

          Show
          Oleg Anashkin added a comment - Please consider implementing this in Doctrine 2.1, my database uses blobs for storing some binary data therefore I can't use doctrine for schema updates anymore - it won't even product the migration sql script.
          Show
          Benjamin Eberlei added a comment - See http://www.doctrine-project.org/docs/orm/2.0/en/reference/basic-mapping.html#custom-mapping-types how to implement a blob type yourself.
          Hide
          Benjamin Eberlei added a comment -

          We should look into creating binary streams for blobs using the data wrapper http://php.net/manual/en/wrappers.data.php for vendors that return strings. I have to look into it in detail though.

          Show
          Benjamin Eberlei added a comment - We should look into creating binary streams for blobs using the data wrapper http://php.net/manual/en/wrappers.data.php for vendors that return strings. I have to look into it in detail though.
          Hide
          Benjamin Eberlei added a comment -

          Implemented BLOB support

          Show
          Benjamin Eberlei added a comment - Implemented BLOB support

            People

            • Assignee:
              Benjamin Eberlei
              Reporter:
              Marc Hodgins
            • Votes:
              4 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: