-
-
Notifications
You must be signed in to change notification settings - Fork 224
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
Disable foreign key checks on purge for all mysql versions #407
base: 1.7.x
Are you sure you want to change the base?
Conversation
... when purge mode is truncate * add test for change of foreign key check when using mysql * add test for not set foreign key check when using sqlite
tests/Doctrine/Tests/Common/DataFixtures/Purger/ORMPurgerForeignKeyCheckTest.php
Outdated
Show resolved
Hide resolved
tests/Doctrine/Tests/Common/DataFixtures/Purger/ORMPurgerForeignKeyCheckTest.php
Outdated
Show resolved
Hide resolved
tests/Doctrine/Tests/Common/DataFixtures/Purger/ORMPurgerForeignKeyCheckTest.php
Outdated
Show resolved
Hide resolved
tests/Doctrine/Tests/Common/DataFixtures/Purger/ORMPurgerForeignKeyCheckTest.php
Outdated
Show resolved
Hide resolved
I initially picked up and rebased this PR to revive or end the discussion around this problem. Now that i looked into it, i understand a few things better:
So would you mind if i rewrite it to address all this? In the same PR? |
I think it's fine to bump the minimum dependency to 3.3, sniffing the
Sure, go ahead 🙂 |
- sniff platform instead of driver - restore variable in MySQL session - only enable/disable once per purge
tests/Doctrine/Tests/Common/DataFixtures/Purger/ORMPurgerForeignKeyCheckTest.php
Outdated
Show resolved
Hide resolved
tests/Doctrine/Tests/Common/DataFixtures/Purger/ORMPurgerForeignKeyCheckTest.php
Outdated
Show resolved
Hide resolved
tests/Doctrine/Tests/Common/DataFixtures/Purger/ORMPurgerForeignKeyCheckTest.php
Outdated
Show resolved
Hide resolved
tests/Doctrine/Tests/Common/DataFixtures/Purger/ORMPurgerForeignKeyCheckTest.php
Outdated
Show resolved
Hide resolved
as suggested Co-authored-by: Grégoire Paris <postmaster@greg0ire.fr>
tests/Doctrine/Tests/Common/DataFixtures/Purger/ORMPurgerForeignKeyCheckTest.php
Outdated
Show resolved
Hide resolved
tests/Doctrine/Tests/Common/DataFixtures/Purger/ORMPurgerForeignKeyCheckTest.php
Outdated
Show resolved
Hide resolved
Co-authored-by: Grégoire Paris <postmaster@greg0ire.fr>
Sorry for the spam. I got nothing to add or change - it's finished for me. Regarding the DBAL (Common?) dependency i also check the previous class in a few easy-to-delete lines. Just in case you want to postpone upping the dependency. |
Reviewers: to be squash-merged |
@SenseException @derrabus can we get another look at this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a functional test with the foreign keys would be a nice-to-have, even though I don't expect breaking changes in the methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 1.5.x branch is closed for features. We need to target 1.7.x now.
$platform = $connection->getDatabasePlatform(); | ||
|
||
if (! class_exists(AbstractMySQLPlatform::class)) { | ||
// before DBAL 3.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to support ancient DBAL versions anymore.
@@ -163,6 +169,8 @@ public function purge() | |||
$connection->executeStatement($platform->getTruncateTableSQL($tbl, true)); | |||
} | |||
} | |||
|
|||
$this->enableForeignKeyChecksForMySQL($connection); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If anything inside the foreach throws, we leave the connection in a state of disabled foreign key checks, don't we? We should do something about that.
public const TEST_TABLE_NAME = 'link'; | ||
|
||
/** @return MappingDriver&MockObject */ | ||
protected function getMockMetadataDriver(): MappingDriver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected function getMockMetadataDriver(): MappingDriver | |
private function getMockMetadataDriver(): MappingDriver |
} | ||
|
||
/** @return Connection&MockObject */ | ||
protected function getMockConnectionForPlatform(AbstractPlatform $platform): Connection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected function getMockConnectionForPlatform(AbstractPlatform $platform): Connection | |
private function getMockConnectionForPlatform(AbstractPlatform $platform): Connection |
For your consideration, see #272. I don't know if the discussion was a yes/no to this feature.
I can push a little refactor of
getTruncateTableSQL()
to make it fit better.