Skip to content
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

Re-allow expressions in UniqueConstraint #1220

Merged
merged 1 commit into from Oct 31, 2022

Conversation

adamchainz
Copy link
Contributor

I have made things!

Re-do of #806 which was unfortunately reverted in the mega PR #909. I’m not sure why it was undone there.

Using @overload because expressions and fields are mutually exclusive: https://github.com/django/django/blob/c01e76c95caa1bd2995f1b6c186cbe8726c92ef9/django/db/models/constraints.py#L147-L150 . Added tests for that behaviour.

Related issues

@knyghty would you like to check? And @linusg, since you spotted the reversion?

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

out: |
main:4: error: No overload variant of "UniqueConstraint" matches argument types "Lower", "List\[str\]", "str"
main:4: note: Possible overload variants:
main:4: note: .*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice usage of regex! 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice plugin, writing all the variants would have been unnecessarily verbose!

Copy link

@linusg linusg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks (as well 😄)!

@sobolevn sobolevn merged commit f566734 into master Oct 31, 2022
@sobolevn sobolevn deleted the unique_constraints_expression branch October 31, 2022 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants