Skip to content

Loading…

DBAL-6: MySQL BLOB datatypes throw DoctrineException::unknownColumnType() exception #1812

Closed
doctrinebot opened this Issue · 11 comments

2 participants

@doctrinebot

Jira issue originally created by user mjh_ca:

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
@doctrinebot

Comment created by @beberlei:

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.

@doctrinebot

Comment created by romanb:

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).

@doctrinebot

Comment created by @beberlei:

@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

@doctrinebot

Comment created by shurakai:

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

@doctrinebot

Comment created by @beberlei:

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.

@doctrinebot

Comment created by extesy:

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.

@doctrinebot

Comment created by @beberlei:

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.

@doctrinebot

Comment created by @beberlei:

Implemented BLOB support

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added the Bug label
@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.2 milestone
@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.