Closed mlazze closed 4 years ago
See https://www.sqlite.org/pragma.html#pragma_foreign_keys
PRAGMA foreign_keys; PRAGMA foreign_keys = boolean;
Query, set, or clear the enforcement of foreign key constraints.
This pragma is a no-op within a transaction; foreign key constraint enforcement may only be enabled or disabled when there is no pending BEGIN or SAVEPOINT.
Whenever enable_static_connection
is enabled it means all test cases are being executed within open database transactions.
If you really need to use this during a test case you might want to try this to bypass the transactional functionalities of this bundle:
public function testForeignKeysWork()
{
\DAMA\DoctrineTestBundle\Doctrine\DBAL\StaticDriver::setKeepStaticConnections(false);
// your code that instantiates a connection and does some PRAGMA things
\DAMA\DoctrineTestBundle\Doctrine\DBAL\StaticDriver::setKeepStaticConnections(true);
}
Thank you! I did not think there was an issue with setting pragma within transaction. As always RTFM applies 😁
I'm actually setting the PRAGMA in a doctrine postConnect listener, I'll try and come up with something which doesn't interfere with the rollback process. Thank you
Hello,
i have the following testcase
For some reason if
enable_static_connection
is true, this fails, but ifenable_static_connection
is false, this succeeds.