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

5.0: Add BaseConstraint.violation_error_code #1969

Merged
merged 1 commit into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions django-stubs/contrib/postgres/constraints.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ class ExclusionConstraint(BaseConstraint):
deferrable: Deferrable | None = ...,
include: list[str] | tuple[str] | None = ...,
opclasses: list[str] | tuple[str] = ...,
violation_error_code: str | None = ...,
violation_error_message: _StrOrPromise | None = ...,
) -> None: ...
9 changes: 8 additions & 1 deletion django-stubs/db/models/constraints.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Deferrable(Enum):

class BaseConstraint:
name: str
violation_error_code: str | None
q0w marked this conversation as resolved.
Show resolved Hide resolved
violation_error_message: _StrOrPromise | None
default_violation_error_message: _StrOrPromise
def __init__(self, name: str, violation_error_message: _StrOrPromise | None = ...) -> None: ...
Expand All @@ -27,7 +28,12 @@ class BaseConstraint:
class CheckConstraint(BaseConstraint):
check: Q | BaseExpression
def __init__(
self, *, check: Q | BaseExpression, name: str, violation_error_message: _StrOrPromise | None = ...
self,
*,
check: Q | BaseExpression,
name: str,
violation_error_code: str | None = ...,
violation_error_message: _StrOrPromise | None = ...,
) -> None: ...

class UniqueConstraint(BaseConstraint):
Expand All @@ -46,6 +52,7 @@ class UniqueConstraint(BaseConstraint):
deferrable: Deferrable | None = ...,
include: Sequence[str] | None = ...,
opclasses: Sequence[Any] = ...,
violation_error_code: str | None = ...,
violation_error_message: _StrOrPromise | None = ...,
) -> None: ...
@overload
Expand Down
6 changes: 0 additions & 6 deletions scripts/stubtest/allowlist_todo_django50.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ django.contrib.gis.admin.options.spherical_mercator_srid
django.contrib.gis.admin.widgets
django.contrib.gis.db.backends.spatialite.schema.SpatialiteSchemaEditor.alter_db_table
django.contrib.gis.db.models.BaseConstraint.__init__
django.contrib.gis.db.models.BaseConstraint.violation_error_code
django.contrib.gis.db.models.Case.allowed_default
django.contrib.gis.db.models.CheckConstraint.__init__
django.contrib.gis.db.models.ExpressionWrapper.allowed_default
django.contrib.gis.db.models.F.allowed_default
django.contrib.gis.db.models.Field.__init__
Expand Down Expand Up @@ -165,9 +163,7 @@ django.db.backends.sqlite3.schema.DatabaseSchemaEditor.sql_alter_table_comment
django.db.backends.utils.CursorWrapper.APPS_NOT_READY_WARNING_MSG
django.db.migrations.serializer.BaseUnorderedSequenceSerializer
django.db.models.BaseConstraint.__init__
django.db.models.BaseConstraint.violation_error_code
django.db.models.Case.allowed_default
django.db.models.CheckConstraint.__init__
django.db.models.ExpressionWrapper.allowed_default
django.db.models.F.allowed_default
django.db.models.Field.__init__
Expand All @@ -188,8 +184,6 @@ django.db.models.QuerySet.update_or_create
django.db.models.Value.allowed_default
django.db.models.When.allowed_default
django.db.models.constraints.BaseConstraint.__init__
django.db.models.constraints.BaseConstraint.violation_error_code
django.db.models.constraints.CheckConstraint.__init__
django.db.models.expressions.BaseExpression.allowed_default
django.db.models.expressions.Case.allowed_default
django.db.models.expressions.CombinedExpression.allowed_default
Expand Down