django-haystack / django-haystack/django-haystack
Can't query datetime fields with an `__exact` query
Open
Nobody has claimed this yet.
needs review
- Dominant language
- Python
- Stars
- 3.7k
- Forks
- 1.3k
- Avg merge
- 3h 18m
- Merged PRs (30d)
- 3
Description
In [1]: from haystack.query import SearchQuerySet
In [2]: import datetime
In [3]: SearchQuerySet().count()
Out[3]: 576
In [5]: SearchQuerySet()[0].when_approved
Out[5]: datetime.datetime(9999, 12, 31, 23, 59, 59, 999999)
In [8]: SearchQuerySet().filter(when_approved__exact=datetime.datetime.max).count()
Out[8]: 0
In [10]: SearchQuerySet().filter(when_approved=datetime.datetime.max).count()
Out[10]: 576
In [9]: SearchQuerySet()[0].when_approved == datetime.datetime.max
Out[9]: True
Both the __exact query and the regular query should return the same results. This is against Haystack master and Whoosh 2.3.2.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the discrepancy with SearchQuerySet().filter using the datetime.max example, then trace the SearchQuerySet filter handling for __exact versus the regular field query. Done means both query forms return the same results for datetime fields, with coverage for the demonstrated case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- search
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100