#36198: Unique Constraints defined with __date lookups on F expressions fail
validation but create database constraints sucessfully
-------------------------------------+-------------------------------------
     Reporter:  Tom Hall             |                    Owner:  (none)
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  5.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  constraint lookup    |             Triage Stage:  Accepted
  unique validation                  |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):

 To me this is a duplicate or at least closely related to #34871 and is due
 to the fact that `models.F("timestamp__date")` is not turned into
 something alike `UnresolvedTransform(F("timestamp"), "date")` which would
 allow proper replacement of `F("timestamp")` by `Value(TIMESTAMP -
 dt.timedelta(days=1), DateLookup._meta.get_field("timestamp"))`.

 The could be ways to resolve this particular issue by adapting
 `F.replace_expressions` when `LOOKUP_SEP in self.name` and the replacement
 (a `Value` instance in the case of constraint validation) has an
 `output_field` though which might be a less invasive solution.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36198#comment:3>
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 visit 
https://groups.google.com/d/msgid/django-updates/0107019519ba625d-c8fdc803-63b5-4d72-a27b-8e60adabba7f-000000%40eu-central-1.amazonses.com.

Reply via email to