{"issue":{"state":"open","pull_request":{"diff_url":null,"html_url":null,"patch_url":null},"user":{"avatar_url":"https://secure.gravatar.com/avatar/556831b9d9c5d5a77e63b6a572179cf5?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"556831b9d9c5d5a77e63b6a572179cf5","url":"https://api.github.com/users/alcohol","login":"alcohol","id":21414},"milestone":null,"labels":[],"assignee":null,"updated_at":"2011-11-02T14:54:38Z","closed_at":null,"comments":3,"url":"https://api.github.com/repos/sebastianbergmann/phpunit/issues/384","body":"When extending PHPUnit_Extensions_Database_TestCase, a TRUNCATE statement seems to be executed for all tables found in the fixture. These TRUNCATE statements result in an Exception.\r\n\r\nThe actual cause for this error is because I am running MySQL 5.5.\r\n\r\n In the manual I found @ http://dev.mysql.com/doc/refman/5.1/en/truncate-table.html\r\n\r\n> \"In MySQL 5.5 and higher, TRUNCATE TABLE is not allowed for InnoDB tables referenced by foreign keys. For ease of upgrading, rewrite such statements to use DELETE instead.\"","html_url":"https://github.com/sebastianbergmann/phpunit/issues/384","number":384,"title":"TRUNCATE statement fails due to FK constraints (MySQL 5.5+)","id":2058165,"created_at":"2011-10-26T15:52:48Z"},"action":"created","comment":{"user":{"avatar_url":"https://secure.gravatar.com/avatar/5ba6d0f60a3117daa3471bc946d68759?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"5ba6d0f60a3117daa3471bc946d68759","url":"https://api.github.com/users/nivl4","login":"nivl4","id":980644},"updated_at":"2011-11-02T14:54:38Z","url":"https://api.github.com/repos/sebastianbergmann/phpunit/issues/comments/2604335","body":"`SET foreign_key_checks = 0;`\r\nis probably not the best solution, since it will not trigger cascade delete.\r\n\r\nHere's a **dirty** hack I put in PHPUnit_Extensions_Database_Operation_Truncate -> execute()\r\n\r\n<pre><code>\r\n$query = 'DELETE FROM '.$connection->quoteSchemaObject($table->getTableMetaData()->getTableName()).';\r\n          ALTER TABLE '.$connection->quoteSchemaObject($table->getTableMetaData()->getTableName()).' AUTO_INCREMENT = 1;';\r\n\r\n</code></pre>","id":2604335,"created_at":"2011-11-02T14:54:38Z"}}