Skip to content
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

Restore UNIQUE_CHECKS mysql variable to its original value when done … #32286

Merged
merged 1 commit into from
Aug 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ public function getDestructiveOperations()
private function startSetupForAllConnections()
{
foreach ($this->sharding->getResources() as $resource) {
$this->resourceConnection->getConnection($resource)
->startSetup();
$this->resourceConnection->getConnection($resource)
->query('SET UNIQUE_CHECKS=0');
$connection = $this->resourceConnection->getConnection($resource);

$connection->startSetup();
$connection->query('SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0');
}
}

Expand All @@ -148,8 +148,10 @@ private function startSetupForAllConnections()
private function endSetupForAllConnections()
{
foreach ($this->sharding->getResources() as $resource) {
$this->resourceConnection->getConnection($resource)
->endSetup();
$connection = $this->resourceConnection->getConnection($resource);

$connection->query('SET UNIQUE_CHECKS=IF(@OLD_UNIQUE_CHECKS=0, 0, 1)');
$connection->endSetup();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function testExecute()
$connectionMock = $this->getMockBuilder(Mysql::class)
->disableOriginalConstructor()
->getMock();
$this->resourceConnectionMock->expects(self::exactly(3))
$this->resourceConnectionMock->expects(self::exactly(2))
->method('getConnection')
->with('default')
->willReturn($connectionMock);
Expand Down