Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.

Don't loose mysql FOREIGN_KEY_CHECKS status #191

Merged
merged 1 commit into from
Jan 23, 2018

Conversation

gsouf
Copy link
Contributor

@gsouf gsouf commented Jun 7, 2017

Hi,

When truncate operation occurs on mysql database the FOREIGN_KEY_CHECKS is modified and when restored, it is set to an arbitrary ("1") value and the previous value is lost.

In some case we use this trick to allow phpunit to populate database from dataset without foreign key errors:

protected function setUp()
    {
        $conn=$this->getConnection();
        $conn->getConnection()->query('set FOREIGN_KEY_CHECKS=0;');
        parent::setUp();
        $conn->getConnection()->query('set FOREIGN_KEY_CHECKS=1;');
    }

The truncate operations conflicts with this and this PR aims to fix that.

@gsouf
Copy link
Contributor Author

gsouf commented Jun 7, 2017

See #37

@sebastianbergmann sebastianbergmann merged commit b8b728e into sebastianbergmann:master Jan 23, 2018
@sebastianbergmann
Copy link
Owner

I merged this pull request without testing it. I do not use DbUnit myself and trust the existing tests as well comments on the pull requests that this does not break anything and solves a problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants