From 41d8ef18ac2d983bea5ef919615687308ffe41c1 Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Tue, 23 Jul 2024 00:33:31 -0400 Subject: [5.0.x] Fixed #35625 -- Fixed a crash when adding a field with db_default and check constraint. This is the exact same issue as refs #30408 but for creating a model with a constraint containing % escapes instead of column addition. All of these issues stem from a lack of SQL and parameters separation from the BaseConstraint DDL generating methods preventing them from being mixed with other parts of the schema alteration logic that do make use of parametrization on some backends (e.g. Postgres, MySQL for DEFAULT). Prior to the addition of Field.db_default and GeneratedField in 5.0 parametrization of DDL was never exercised on model creation so this is effectively a bug with db_default as the GeneratedField case was addressed by refs #35336. Thanks Julien Chaumont for the report and Mariusz Felisiak for the review. Backport of f359990e4909db8722820849d61a6f5724338723 from main. --- docs/releases/5.0.8.txt | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'docs') diff --git a/docs/releases/5.0.8.txt b/docs/releases/5.0.8.txt index 1037b78f75..7bdb5488b2 100644 --- a/docs/releases/5.0.8.txt +++ b/docs/releases/5.0.8.txt @@ -15,3 +15,7 @@ Bugfixes * Fixed a regression in Django 5.0 where ``ModelAdmin.action_checkbox`` could break the admin changelist HTML page when rendering a model instance with a ``__html__`` method (:ticket:`35606`). + +* Fixed a crash when creating a model with a ``Field.db_default`` and a + ``Meta.constraints`` constraint composed of ``__endswith``, ``__startswith``, + or ``__contains`` lookups (:ticket:`35625`). -- cgit v1.3