#9596: Comparing a DateTimeField to a date is too hard -------------------------------------+------------------------------------- Reporter: django@… | Owner: nobody Type: New feature | Status: new Component: Database layer | Version: SVN (models, ORM) | Resolution: Severity: Normal | Triage Stage: Accepted Keywords: lookup_type date | Needs documentation: 0 datetimefield compare comparison | Patch needs improvement: 1 query_term field lookup | UI/UX: 0 Has patch: 1 | Needs tests: 0 | Easy pickings: 0 | -------------------------------------+------------------------------------- Changes (by aaugustin):
* stage: Design decision needed => Accepted Comment: This ticket is in DDN because the current technique fails if the `__date` lookup is used on a `DateField`. There is exactly the same problem with the `year` lookup; its implementation depends on the field it's applied to: {{{ # django/db/models/fields/__init__.py elif lookup_type == 'year': if self.get_internal_type() == 'DateField': return connection.ops.year_lookup_bounds_for_date_field(value) else: return connection.ops.year_lookup_bounds(value) }}} The implementation of `year_lookup_bounds` and `year_lookup_bounds_for_date_field` is database dependent. This allows setting the upper bound to `YYYY-12-31` instead of `YYYY-12-31 23:59:59.999999` for `DateField`s under Oracle. I think we could mirror this solution for the `__date` lookup. This means implementing `connection.ops.date_lookup_bounds(value)` `connection.ops.date_lookup_bounds_for_date_field(value)` (in a backend dependent fashion if necessary). It would be even better to convert the lookup to an exact match for `DateField`, but I don't believe that's doable with the current implementation. Note that the tests in the patch need to be rewritten as unittests. -- Ticket URL: <https://code.djangoproject.com/ticket/9596#comment:23> 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 post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.