Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes #2993, Refs #2918 -- Reverted [3960]; [3960] fixed a potential …

…data validation problem for SQLite, but broke usage of LazyDate. The proper fix is to complete the model validators to catch _all_ invalid inputs.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4105 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 95d19384c06d3e6d5e71774d4a63a967b9f25331 1 parent 8379785
@freakboy3742 freakboy3742 authored
Showing with 2 additions and 11 deletions.
  1. +2 −11 django/db/models/fields/__init__.py
View
13 django/db/models/fields/__init__.py
@@ -457,9 +457,7 @@ def get_follow(self, override=None):
def get_db_prep_save(self, value):
# Casts dates into string format for entry into database.
- if isinstance(value, datetime.datetime):
- value = value.date().strftime('%Y-%m-%d')
- elif isinstance(value, datetime.date):
+ if value is not None:
value = value.strftime('%Y-%m-%d')
return Field.get_db_prep_save(self, value)
@@ -489,19 +487,12 @@ def to_python(self, value):
def get_db_prep_save(self, value):
# Casts dates into string format for entry into database.
- if isinstance(value, datetime.datetime):
+ if value is not None:
# MySQL will throw a warning if microseconds are given, because it
# doesn't support microseconds.
if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'):
value = value.replace(microsecond=0)
value = str(value)
- elif isinstance(value, datetime.date):
- # MySQL will throw a warning if microseconds are given, because it
- # doesn't support microseconds.
- if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'):
- value = datetime.datetime(value.year, value.month, value.day, microsecond=0)
- value = str(value)
-
return Field.get_db_prep_save(self, value)
def get_db_prep_lookup(self, lookup_type, value):
Please sign in to comment.
Something went wrong with that request. Please try again.