﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
26824	MySQL query with CONVERT_TZ is not properly formated	Luboš Truhlář	nobody	"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,
        }
    }
}
}}}
"	Bug	closed	Database layer (models, ORM)	1.9	Normal	invalid	mysql, timezone		Unreviewed	0	0	0	0	0	0
