diff options
| author | Xavier Fernandez <xavier.fernandez@beta.gouv.fr> | 2023-02-22 21:04:05 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-02-23 05:35:58 +0100 |
| commit | 51c9bb7cd16081133af4f0ab6d06572660309730 (patch) | |
| tree | 32d561be83447b8d372d0b9d4d9d29eebf2810da /django/db/models | |
| parent | dcd974698301a38081c141ccba6dcafa5ed2c80e (diff) | |
| download | django-51c9bb7cd16081133af4f0ab6d06572660309730.tar.gz | |
Refs #33829 -- Added violation_error_message to constraints' __repr__().
Diffstat (limited to 'django/db/models')
| -rw-r--r-- | django/db/models/constraints.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/django/db/models/constraints.py b/django/db/models/constraints.py index 237b186050..075ecee1be 100644 --- a/django/db/models/constraints.py +++ b/django/db/models/constraints.py @@ -117,10 +117,16 @@ class CheckConstraint(BaseConstraint): pass def __repr__(self): - return "<%s: check=%s name=%s>" % ( + return "<%s: check=%s name=%s%s>" % ( self.__class__.__qualname__, self.check, repr(self.name), + ( + "" + if self.violation_error_message is None + or self.violation_error_message == self.default_violation_error_message + else " violation_error_message=%r" % self.violation_error_message + ), ) def __eq__(self, other): @@ -287,7 +293,7 @@ class UniqueConstraint(BaseConstraint): ) def __repr__(self): - return "<%s:%s%s%s%s%s%s%s>" % ( + return "<%s:%s%s%s%s%s%s%s%s>" % ( self.__class__.__qualname__, "" if not self.fields else " fields=%s" % repr(self.fields), "" if not self.expressions else " expressions=%s" % repr(self.expressions), @@ -296,6 +302,12 @@ class UniqueConstraint(BaseConstraint): "" if self.deferrable is None else " deferrable=%r" % self.deferrable, "" if not self.include else " include=%s" % repr(self.include), "" if not self.opclasses else " opclasses=%s" % repr(self.opclasses), + ( + "" + if self.violation_error_message is None + or self.violation_error_message == self.default_violation_error_message + else " violation_error_message=%r" % self.violation_error_message + ), ) def __eq__(self, other): |
