Skip to content

Fix #45 correctly reinstate nullable unique constraints #47

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

Merged

Conversation

sparrowt
Copy link

Ensure that the unique/unique_together constraint which is reinstated, is exactly the same as the one that was dropped earlier on in _alter_field before e.g. altering the column type.

This fixes both cases described on the bug report, i.e. when AlterField modifies a column which is:

  1. individually unique=True as well as null=True
  2. in a unique_together where at least 1 column is nullable

First commit adds tests for both cases which fail without the fix & pass with it.

Ensure that the unique/unique_together constraint is
reinstated exactly the same as the one that was dropped
earlier in `_alter_field`

This fixes both cases described on the bug report, that
is when `AlterField` modifies a column which is:
 1) individually `unique=True` as well as `null=True`
 2) in a `unique_together` where at least 1 column is nullable
@sparrowt sparrowt changed the title Fix #45 correctly reinstate nullable unique/unique_together Fix #45 correctly reinstate nullable unique constraints Mar 31, 2020
@sparrowt
Copy link
Author

sparrowt commented Apr 2, 2020

The unit tests for this project (including those added by this PR) are passing ✔️

Though I did notice that they are now run with --keepdb since #43 which is possibly problematic - because we need all the testapp migrations to run every time as they are part of the tests really. Is the database actually re-used between test runs?
If so then I wonder if --keepdb should be removed.
If not then I guess the --keepdb flag is doing nothing anyway? (other than for devs locally)

@OskarPersson
Copy link
Collaborator

Great work, thank you! The --keepdb shouldn't affect the CI since a new virtual machine is created each time and never has the old DB. It's mostly for local dev.

@OskarPersson OskarPersson merged commit b5a8b10 into ESSolutions:master Apr 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nullable unique constraints not reinstated correctly
2 participants