#34840: Django 4.2 casts text fields when testing IS NULL, preventing use of
partial indexes
-------------------------------------+-------------------------------------
     Reporter:  Alex Vandiver        |                    Owner:  murtatah
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  4.2
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Florian Apolloner):

 Running the tests with server side param binding enabled and having
 removed the cast for `IS NULL` results in three failures:
 {{{
 ======================================================================
 ERROR: test_model_validation_with_condition
 (constraints.tests.UniqueConstraintTests.test_model_validation_with_condition)
 Partial unique constraints are not ignored by
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "/usr/lib64/python3.11/unittest/case.py", line 57, in
 testPartExecutor
     yield
   File "/usr/lib64/python3.11/unittest/case.py", line 623, in run
     self._callTestMethod(testMethod)
     ^^^^^^^^^^^^^^^^^
   File "/usr/lib64/python3.11/unittest/case.py", line 579, in
 _callTestMethod
     if method() is not None:
     ^^^^^^^^^^^^^^^^^
   File "/home/florian/sources/django.git/django/test/testcases.py", line
 1425, in skip_wrapper
     return test_func(*args, **kwargs)
     ^^^^^^^^^^^^^^^^^
   File "/home/florian/sources/django.git/tests/constraints/tests.py", line
 804, in test_model_validation_with_condition
     ).validate_constraints()
     ^^^^^^^^^^^^^^^^^
   File "/home/florian/sources/django.git/django/db/models/base.py", line
 1497, in validate_constraints
     raise ValidationError(errors)
     ^^^^^^^^^^^^^^^^^
 django.core.exceptions.ValidationError: {'__all__': ['Constraint
 “name_without_color_uniq” is violated.']}

 ======================================================================
 ERROR: test_validate_condition
 (constraints.tests.UniqueConstraintTests.test_validate_condition)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "/usr/lib64/python3.11/unittest/case.py", line 57, in
 testPartExecutor
     yield
   File "/usr/lib64/python3.11/unittest/case.py", line 623, in run
     self._callTestMethod(testMethod)
     ^^^^^^^^^^^^^^^^^
   File "/usr/lib64/python3.11/unittest/case.py", line 579, in
 _callTestMethod
     if method() is not None:
     ^^^^^^^^^^^^^^^^^
   File "/home/florian/sources/django.git/django/test/testcases.py", line
 1425, in skip_wrapper
     return test_func(*args, **kwargs)
     ^^^^^^^^^^^^^^^^^
   File "/home/florian/sources/django.git/tests/constraints/tests.py", line
 879, in test_validate_condition
     constraint.validate(
     ^^^^^^^^^^^^^^^^^
   File "/home/florian/sources/django.git/django/db/models/constraints.py",
 line 461, in validate
     raise ValidationError(
     ^^^^^^^^^^^^^^^^^
 django.core.exceptions.ValidationError: ['Constraint
 “name_without_color_uniq” is violated.']

 ======================================================================
 ERROR: test_validate_expression_condition
 (constraints.tests.UniqueConstraintTests.test_validate_expression_condition)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "/usr/lib64/python3.11/unittest/case.py", line 57, in
 testPartExecutor
     yield
   File "/usr/lib64/python3.11/unittest/case.py", line 623, in run
     self._callTestMethod(testMethod)
     ^^^^^^^^^^^^^^^^^
   File "/usr/lib64/python3.11/unittest/case.py", line 579, in
 _callTestMethod
     if method() is not None:
     ^^^^^^^^^^^^^^^^^
   File "/home/florian/sources/django.git/tests/constraints/tests.py", line
 965, in test_validate_expression_condition
     constraint.validate(
     ^^^^^^^^^^^^^^^^^
   File "/home/florian/sources/django.git/django/db/models/constraints.py",
 line 461, in validate
     raise ValidationError(
     ^^^^^^^^^^^^^^^^^
 django.core.exceptions.ValidationError: ['Constraint
 “name_lower_without_color_uniq” is violated.']

 ----------------------------------------------------------------------
 Ran 16695 tests in 201.401s
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34840#comment:11>
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/0107018a9dccc43e-c6b633ba-f4c2-48aa-be51-38e6546c74e3-000000%40eu-central-1.amazonses.com.

Reply via email to