Skip to content

Commit 08c6a65

Browse files
akeemanfabpot
authored andcommitted
[Cache] [PdoAdapter] Fix MySQL 1170 error (blob as primary key)
1 parent 84d0da2 commit 08c6a65

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Symfony/Component/Cache/Adapter/PdoAdapter.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,20 @@ public function createTable()
108108
$conn = $this->getConnection();
109109

110110
if ($conn instanceof Connection) {
111+
$types = array(
112+
'mysql' => 'binary',
113+
'sqlite' => 'text',
114+
'pgsql' => 'string',
115+
'oci' => 'string',
116+
'sqlsrv' => 'string',
117+
);
118+
if (!isset($types[$this->driver])) {
119+
throw new \DomainException(sprintf('Creating the cache table is currently not implemented for PDO driver "%s".', $this->driver));
120+
}
121+
111122
$schema = new Schema();
112123
$table = $schema->createTable($this->table);
113-
$table->addColumn($this->idCol, 'blob', array('length' => 255));
124+
$table->addColumn($this->idCol, $types[$this->driver], array('length' => 255));
114125
$table->addColumn($this->dataCol, 'blob', array('length' => 16777215));
115126
$table->addColumn($this->lifetimeCol, 'integer', array('unsigned' => true, 'notnull' => false));
116127
$table->addColumn($this->timeCol, 'integer', array('unsigned' => true, 'foo' => 'bar'));

0 commit comments

Comments
 (0)