Created
August 3, 2011 18:53
-
-
Save jmikola/1123476 to your computer and use it in GitHub Desktop.
[DDC-1317] @column(unique=true) is not semantically equivalent to @UniqueConstraint and yields invalid SQL for table create statements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ opensky/console doctrine:schema:update --force | |
Updating database schema... | |
string(186) "CREATE TABLE Parameter (id INT AUTO_INCREMENT NOT NULL, key VARCHAR(255) NOT NULL, value VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_A86613B38A90ABA9 (key), PRIMARY KEY(id)) ENGINE = InnoDB" | |
string(2333) "#0 /home/jmikola/workspace/opensky/vendor/doctrine-dbal/lib/Doctrine/DBAL/Connection.php(618): PDO->query('CREATE TABLE Pa...') | |
#1 /home/jmikola/workspace/opensky/vendor/doctrine/lib/Doctrine/ORM/Tools/SchemaTool.php(641): Doctrine\DBAL\Connection->executeQuery('CREATE TABLE Pa...') | |
#2 /home/jmikola/workspace/opensky/vendor/doctrine/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php(86): Doctrine\ORM\Tools\SchemaTool->updateSchema(Array, true) | |
#3 /home/jmikola/workspace/opensky/vendor/doctrine/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php(59): Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand->executeSchemaCommand(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput), Object(Doctrine\ORM\Tools\SchemaTool), Array) | |
#4 /home/jmikola/workspace/opensky/vendor/symfony/src/Symfony/Bundle/DoctrineBundle/Command/Proxy/UpdateSchemaDoctrineCommand.php(63): Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) | |
#5 /home/jmikola/workspace/opensky/vendor/symfony/src/Symfony/Component/Console/Command/Command.php(187): Symfony\Bundle\DoctrineBundle\Command\Proxy\UpdateSchemaDoctrineCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) | |
#6 /home/jmikola/workspace/opensky/vendor/symfony/src/Symfony/Component/Console/Application.php(191): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) | |
#7 /home/jmikola/workspace/opensky/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(75): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) | |
#8 /home/jmikola/workspace/opensky/vendor/symfony/src/Symfony/Component/Console/Application.php(117): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) | |
#9 /home/jmikola/workspace/opensky/opensky/console(16): Symfony\Component\Console\Application->run() | |
#10 {main}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Doctrine\ORM\Mapping as ORM; | |
/** @ORM\Entity */ | |
class Parameter | |
{ | |
/** | |
* @ORM\Id | |
* @ORM\Column(type="integer") | |
* @ORM\GeneratedValue | |
*/ | |
protected $id; | |
/** | |
* @ORM\Column(type="string", unique=true) | |
*/ | |
protected $key; | |
/** @ORM\Column(type="string") */ | |
protected $value; | |
} | |
Yup, I realized that after I took the snapshot :)
The exception message was just standard PDO stuff, with only a portion of the full SQL query - that's why I popped in to debug the full query and trace.
I'm really not sure why unique=true
failed for me. If this can't be reproduced by anyone on the Doctrine team I'll be happy to put it to rest.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ah sorry, Confused UniqueConstraint and UniqueEntity.
unique=true works well for me. the difference is that it cannot be used to create multi fields constraints.
Btw, your output is not complete: the exception message is missing, there is only the stack trace.