ibmdb / python-ibmdb-django

IBM DB2 Driver for the Django application Framework
Apache License 2.0
29 stars 42 forks source link

schemaEditor: make primary keys enforced #93

Closed 0x2ec closed 11 months ago

0x2ec commented 1 year ago

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.

0x2ec commented 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.

praveen-db2 commented 11 months ago

@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.