#34805: 'Q' object has no attribute 'replace_expressions'
-----------------------------------------+------------------------
               Reporter:  Petr Přikryl   |          Owner:  nobody
                   Type:  Uncategorized  |         Status:  new
              Component:  Uncategorized  |        Version:  4.2
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 Hi, I have problem with calling full_clean on Model object with following
 constraint containing Q:

 {{{
 models.UniqueConstraint(
     models.Q(color__isnull=True),
     "product",
     condition=models.Q(color__isnull=True),
     name="unique_product_color_null",
 ),
 }}}

 Constraint is allowing only one NULL and works well. More at
 [https://www.enterprisedb.com/postgres-tutorials/postgresql-unique-
 constraint-null-allowing-only-one-null]

 Traceback
 {{{
 /usr/local/lib/python3.11/site-packages/django/db/models/base.py:1497: in
 full_clean
     self.validate_constraints(exclude=exclude)
 /usr/local/lib/python3.11/site-packages/django/db/models/base.py:1445: in
 validate_constraints
     constraint.validate(model_class, self, exclude=exclude, using=using)

 /usr/local/lib/python3.11/site-
 packages/django/db/models/constraints.py:346: AttributeError
 >               expressions.append(Exact(expr,
 expr.replace_expressions(replacements)))
 E               AttributeError: 'Q' object has no attribute
 'replace_expressions'
 }}}

 
https://github.com/django/django/blob/4.2.4/django/db/models/constraints.py#L346

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34805>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018a4647daf4-5c34c02e-1be4-43bd-a5f7-fa300d7ffbd1-000000%40eu-central-1.amazonses.com.

Reply via email to