-
-
Notifications
You must be signed in to change notification settings - Fork 33k
Fixed #29824 -- Added support for database exclusion constraints on PostgreSQL. #10478
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
Conversation
fac7ab0
to
8c2709e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your work on this!
48bae6b
to
fe815e7
Compare
Is it ready for review or still WIP as mentioned in the commit message? |
@timgraham I'd like to have an example as requested because there may be many (I've at least worked with one) existing installations of Django which implement a table with two fields, rather than using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and please rebase :)
fe815e7
to
924c094
Compare
57d5855
to
8a2f31f
Compare
I'm clueless how to fix the failing tests on the databases that are irrelevant for this patch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @atombrella!
Thanks for tackling this - will be an awesome addition. I've had a first pass through this - I think that there is some validation that needs attending to and I have some questions about simplifying the API...
f251951
to
a187867
Compare
@ngnpope Thank you 👍 I think I've addressed most of the feedback that was possible. Remaining issues are related to Tests are failing on unrelated database backends, and suggested method of silencing with The docs part of the test fails because of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have to have a think about your questions - hopefully I'll have some time later this week.
733b682
to
a2c42ab
Compare
5291113
to
facc286
Compare
@atombrella I've prepared first commit (with Quick comments:
I'm going to review in details remaining docs and tests in the next week. |
@felixxm Yes, some of those operators may not be relevant. But I don't think it'll hurt to add them. I'll try to think of a way to test them. I think @ngnpope gave the documentation a pretty good first review, so I don't think a review of this part will be tricky :) The tests have not yet really been looked at. |
@atombrella I think that only Thanks for understanding. |
ec043de
to
c531eba
Compare
@felixxm I removed those three operators. The easiest way I could think that fulfills this was using the examples in PostgreSQL documentation and |
c531eba
to
914169b
Compare
e318ec5
to
aa172ef
Compare
@atombrella I made some changes:
My plan for tomorrow is to review remaining docs and add tests for exclusion constraints with other operators. |
👍 to |
@atombrella Only commutative operators can be used in exclusion constraints, so I'm going to remove currently unused |
@atombrella Without |
I added test for |
@felixxm OK. Maybe you should add |
aa0d8df
to
2d7c6fb
Compare
@atombrella You're a 🌟 ! I refactored docs and moved exclusion constraints to the main section instead of minor features, It's not minor 🚀 . Now I'm happy 😉 |
…ostgreSQL. Thanks to Nick Pope and Mariusz Felisiak for review. Co-Authored-By: Mariusz Felisiak <[email protected]>
@atombrella Many thanks 🚀 🎊 Thanks y'all for comments and reviews 🙇♂️ |
It should be cleaned up, but here's a good first take on adding the exclude using constraint to
django.contrib.postgres
. Essentially, it's a way to enforce a unique constraint for a range, whether they're represented as a range-type, or using two fields.https://gist.github.com/fphilipe/0a2a3d50a9f3834683bf uses two fields, and overlaps with the documentation example where cars are used to illustrate how it works.
I was lucky that
RemoveConstraint
works, as the constraint can also be removed usingDROP INDEX ...
.https://code.djangoproject.com/ticket/29824
Maybe write some tests for abstract models. There's Fixed #30397 -- Added app_label/class interpolation for names of indexes and constraints. #11279 that's a necessity for this.