#26824: MySQL query with CONVERT_TZ is not properly formated
----------------------------------------------+----------------------------
Reporter: truhlik | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: 1.9
Severity: Normal | Keywords: mysql,
| timezone
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+----------------------------
Hi,
I think that there is a bug in ORM if queryset using '__date' and
TIMEZONE.
This code:
{{{
queryset = queryset.filter(created_at__date__lte=created_at_to.date())
}}}
produces this SQL query:
{{{
SELECT ... FROM `payments_payment` WHERE
DATE(CONVERT_TZ(`payments_payment`.`created_at`, 'UTC', Europe/Prague)) <=
2016-06-30)
}}}
The problem is that 'Europe/Prague' is not in the quotes! Mysql returns
this error:
{{{
#1054 - Unknown column 'Europe' in 'where clause'
}}}
my settings.py
{{{
TIME_ZONE = "Europe/Prague"
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'reality_15062016',
'PORT': '3306',
'TIME_ZONE': 'Europe/Prague',
'OPTIONS': {
'charset': 'utf8',
'use_unicode': True,
}
}
}
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26824>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.145fc5e450d6541379d7daaff025bfc1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.