Closed 0x2ec closed 1 year ago
I'm not certain that this is the right/full fix - maybe unique keys should also be created as ENFORCED?
The documentation for the oldest version of DB2 I could find talks about ENFORCED/NOT ENFORCED: https://www.ibm.com/docs/en/db2/9.7?topic=constraints-creating-modifying, but I haven't found any documentation that says that the default is NOT ENFORCED.
@0x2ec whatever we have now is correct code, I had run this adapter against complete Django test suite, where many test suites checks whether constraints are enforced or not. Will close this PR is not required.
Discovered during runs of
./manage.py loaddata
, it turns out that for the version of DB2 I'm using (either 10 or 11) that primary keys are not ENFORCED by default. None of the primary key, unique key, or FK constraints were created as ENFORCED.This would lead to an error when enable_constraint_checking() tries to set FK constraints to ENFORCED as the referenced keys would not themselves be ENFORCED.