django-rest-framework icon indicating copy to clipboard operation
django-rest-framework copied to clipboard

Support UniqueConstraint

Open kalekseev opened this issue 5 years ago • 11 comments

A starting point for discussion, that pr supports both cases when UniqueConstraint consist of one field -> UniqueValidator, and several fields -> UniqueTogetherValidator. The implementation of single field unique validator is quite naive where we loop over all constraints searching for single field constraints and we do it for each field, would be good to cache that somehow.

refs #7173

kalekseev avatar Jul 29 '20 15:07 kalekseev

@carltongibson @tomchristie can we add this to 3.12 milestone? I'm ready to contribute updates to the patch as requested.

kalekseev avatar Aug 07 '20 11:08 kalekseev

Hi @kalekseev. Yes. Super. It's just waiting for a bit of capacity to review. Thanks 👍

carltongibson avatar Aug 07 '20 11:08 carltongibson

I believe a test case for the serializer error message would be good to have to ensure the message is as expected. Currently it seems like any message is "good enough" which might cause unwanted/unexpected effects

NyanKiyoshi avatar Mar 01 '21 10:03 NyanKiyoshi

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 27 '22 19:03 stale[bot]

It's not stale, still waiting review from maintainers.

kalekseev avatar Mar 27 '22 20:03 kalekseev

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 31 '22 04:05 stale[bot]

Bump

JorgenPhi avatar May 31 '22 07:05 JorgenPhi

Just to comment to re-flag this as a change worth having. ORM Constraints are getting increasingly rounded out, and as such are the expected API going forward.

carltongibson avatar Jun 01 '22 06:06 carltongibson

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 13 '22 03:08 stale[bot]

Not stale, I will rebase as soon as someone is ready to review. Probably can be superseded by https://github.com/encode/django-rest-framework/issues/7173#issuecomment-1122490298

kalekseev avatar Aug 15 '22 07:08 kalekseev

Not stale, I will rebase as soon as someone is ready to review. Probably can be superseded by #7173 (comment)

so drf level validation might not needed?

auvipy avatar Sep 01 '22 14:09 auvipy

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 01 '22 14:11 stale[bot]

Not stale, I will rebase as soon as someone is ready to review. Probably can be superseded by #7173 (comment)

if you re start this, with modified approach, I can commit you thorough review for this

auvipy avatar Nov 21 '22 12:11 auvipy

as we still support django 3.0, so we might still follow the approach in this PR. considering the fact that django orm level validation is available in 4.1 mostly.

auvipy avatar Nov 21 '22 13:11 auvipy

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 21 '23 03:01 stale[bot]

@auvipy rebased

kalekseev avatar Jan 25 '23 17:01 kalekseev

I will review it timorrow

auvipy avatar Jan 25 '23 17:01 auvipy

@auvipy rebased

can we check https://docs.djangoproject.com/en/4.0/ref/models/constraints/ and see if we could cover more test cases/edge cases here?

auvipy avatar Jan 26 '23 06:01 auvipy

@auvipy rebased

can we check https://docs.djangoproject.com/en/4.0/ref/models/constraints/ and see if we could cover more test cases/edge cases here?

The pr lack of support for *expressions that were added recently, I will look into it when I have time.

kalekseev avatar Jan 26 '23 08:01 kalekseev

@auvipy rebased

can we check https://docs.djangoproject.com/en/4.0/ref/models/constraints/ and see if we could cover more test cases/edge cases here?

The pr lack of support for *expressions that were added recently, I will look into it when I have time.

If you can handle the new API's in this PR it would be really great.

auvipy avatar Mar 01 '23 15:03 auvipy

@auvipy this is in my backlog, unfortunately I'm crushed with work right now, not sure when I'll be able to review it

as we still support django 3.0, so we might still follow the approach in this PR. considering the fact that django orm level validation is available in 4.1 mostly.

Is there a work done to introduce support for new django validation into DRF?

kalekseev avatar Mar 03 '23 06:03 kalekseev

not really. in that case we can move forward with the current implementation of this patch for now and implement the new API's in another take.

auvipy avatar Mar 03 '23 07:03 auvipy