[Django] #24189: Filtering by month or day doesn't work with MySQL

44 views
Skip to first unread message

Django

unread,
Jan 20, 2015, 9:29:31 AM1/20/15
to django-...@googlegroups.com
#24189: Filtering by month or day doesn't work with MySQL
-------------------------------------+-------------------------------------
Reporter: unaizalakain | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.7
(models, ORM) | Keywords: datetime, timezone,
Severity: Normal | date, month, day
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
While filtering by year works, filtering by month or by date doesn't:

{{{
In [1]: from planner.tasks.models import KeyDate

In [2]: KeyDate.objects.all()
Out[2]: [<KeyDate: Revision>, <KeyDate: Production>]

In [3]: KeyDate.objects.all()[0].date
Out[3]: datetime.datetime(2015, 1, 20, 14, 1, 20, tzinfo=<UTC>)

In [4]: KeyDate.objects.filter(date__year=2015)
Out[4]: [<KeyDate: Revision>, <KeyDate: Production>]

In [5]: KeyDate.objects.filter(date__month=1)
Out[5]: []
}}}

If I switch to SQLite everything works as expected.

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

Django

unread,
Jan 20, 2015, 10:14:29 AM1/20/15
to django-...@googlegroups.com
#24189: Filtering by month or day doesn't work with MySQL
-------------------------------------+-------------------------------------
Reporter: unaizalakain | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 1.7
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: datetime, timezone, | Triage Stage:
date, month, day | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by unaizalakain):

* status: new => closed
* needs_better_patch: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_docs: => 0


Comment:

After injecting timezone definitions it didn't work neither... until I
restarted the MySQL server.

--
Ticket URL: <https://code.djangoproject.com/ticket/24189#comment:1>

Django

unread,
Jan 20, 2015, 11:50:17 AM1/20/15
to django-...@googlegroups.com
#24189: Filtering by month or day doesn't work with MySQL
-------------------------------------+-------------------------------------
Reporter: unaizalakain | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 1.7
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: datetime, timezone, | Triage Stage:
date, month, day | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by aaugustin):

MySQL thinks it's a good idea to return invalid results silently when
something goes wrong. I'm sorry to hear that you have to use it.

--
Ticket URL: <https://code.djangoproject.com/ticket/24189#comment:2>

Django

unread,
Jan 20, 2015, 12:13:33 PM1/20/15
to django-...@googlegroups.com
#24189: Filtering by month or day doesn't work with MySQL
-------------------------------------+-------------------------------------
Reporter: unaizalakain | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 1.7
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: datetime, timezone, | Triage Stage:
date, month, day | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by unaizalakain):

Replying to [comment:2 aaugustin]:


> MySQL thinks it's a good idea to return invalid results silently when
something goes wrong. I'm sorry to hear that you have to use it.

I'm sorry too, believe me, it's the first time I had to use MySQL and,
compared to using PostgreSQL it's not a pleasant experience ... I hope we
will eventually change to PostgreSQL...

--
Ticket URL: <https://code.djangoproject.com/ticket/24189#comment:3>

Reply all
Reply to author
Forward
0 new messages