-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix truncate on MySQL >= 5.5 #549
Conversation
Hello, thank you for creating this pull request. I have automatically opened an issue http://www.doctrine-project.org/jira/browse/DBAL-844 We use Jira to track the state of pull requests and the versions they got |
@ddeboer this could need a test, as well as a small functional test that could be useful to identify whether the behavior changes in MySQL and if people installing the DBAL actually can change these settings (running the test suite can reveal incompatibilities). I don't like this, but I guess MySQL can't be helped :( |
@Ocramius How about using some kind of |
@ddeboer I'm not sure whether we should add this behaviour for MySQL 5.5.7 and onwards only and avoid disabling foreign key checks by default for lower versions. Also I still find it rather dangerous just disabling the integrity checks by default. I would like to have a more explicit possiblity to get this behaviour so that the "normal" |
@Ocramius I’ll come up with a test once we’ve agreed on where and how to add this fix. @deeky666 Are you suggesting to move the Another option would be to replace truncate with a delete and resetting the auto-increment. That way, we wouldn’t have to disable foreign key checks. |
@tPl0ch Interesting solution. But by requiring a user parameter ( |
@ddeboer Hmm, assuming |
Closing here. For an explanation to why we won't / can't do anything in DBAL please see: #2620 |
When truncating tables on MySQL >= 5.5, an error is thrown:
It turns out that with MySQL 5.5.7,
TRUNCATE
behaviour has changed. From the MySQL docs:This PR disables foreign key checks just before, and re-enables them just after, truncate.
As I encountered this issue using doctrine/data-fixtures, I originally submitted a fix there: doctrine/data-fixtures#127. However, as @deeky666 pointed out, the DBAL is a better place for the fix.