﻿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
3301	[multi-db] Bug in Fields.DateTimeField.pre_save()	eric.helvey@…	nobody	"super call explicity names DateField instead of DateTimeField, thus bypassing the DateField.pre_save method that was intended.  This causes DateTimeFields 

Current:
    def pre_save(self, model_instance, add):
        value = super(DateField, self).pre_save(model_instance, add)
        if value is not None:
            # MySQL will throw a warning if microseconds are given, because it
            # doesn't support microseconds.
            settings = model_instance._default_manager.db.connection.settings
            if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'):
                value = value.replace(microsecond=0)
        return value


Fixed:
    def pre_save(self, model_instance, add):
        value = super(DateTimeField, self).pre_save(model_instance, add)
        if value is not None:
            # MySQL will throw a warning if microseconds are given, because it
            # doesn't support microseconds.
            settings = model_instance._default_manager.db.connection.settings
            if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'):
                value = value.replace(microsecond=0)
        return value
"	defect	closed	Database layer (models, ORM)	other branch	normal	fixed			Someday/Maybe	1	0	0	0	0	0
