Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

jdufresne
Copy link
Member

UniqueDeferred can be used to create a deferred unique constraint. For class based unique constraints to integrate with model forms, a new Index.get_unique_checks() was added to communicate to the model which fields should be considered during unique validation.

https://code.djangoproject.com/ticket/20581

UniqueDeferred can be used to create a deferred unique constraint. For
class based unique constraints to integrate with model forms, a new
Index.get_unique_checks() was added to communicate to the model which
fields should be considered during unique validation.
@akki
Copy link
Contributor

akki commented Jun 10, 2017

Thanks for the patch.

There is one point of concern that I have with this approach of making a new class for unique indexes.
Actually "unique" is not a type of index (unlike BTree, Hash, etc.), "unique" is like a property for any index. During the implementation of the index class I had imagined unique as another parameter of the Index class instead of a whole new class (and this was also discussed somewhere on the mailing list but I can't find it right now).
If we go further with this implementation we might end up making indexes like GinUnique, GistUnique, GinUniqueDeferred, GistUniqueDeferred, etc. in the future, so just wanted to highlight this.

@charettes
Copy link
Member

I agree with @akki on this one. I feel like deferred should be a kwarg to a base Constraint subclass which overlaps a bit with #7615.

@jdufresne
Copy link
Member Author

Thanks for the feedback. I'll wait for the other PR to be resolved and try a new patch leveraging the Constraint class.

@jdufresne jdufresne closed this Jun 13, 2017
@jdufresne jdufresne deleted the unique-defer branch June 26, 2017 20:58
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.

3 participants