Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Russell Keith-Magee authored November 26, 2006

Showing 1 changed file with 2 additions and 11 deletions. Show diff stats Hide diff stats

  1. 13  django/db/models/fields/__init__.py
13  django/db/models/fields/__init__.py
@@ -457,9 +457,7 @@ def get_follow(self, override=None):
457 457
 
458 458
     def get_db_prep_save(self, value):
459 459
         # Casts dates into string format for entry into database.
460  
-        if isinstance(value, datetime.datetime):
461  
-            value = value.date().strftime('%Y-%m-%d')
462  
-        elif isinstance(value, datetime.date):
  460
+        if value is not None:
463 461
             value = value.strftime('%Y-%m-%d')
464 462
         return Field.get_db_prep_save(self, value)
465 463
 
@@ -489,19 +487,12 @@ def to_python(self, value):
489 487
 
490 488
     def get_db_prep_save(self, value):
491 489
         # Casts dates into string format for entry into database.
492  
-        if isinstance(value, datetime.datetime):
  490
+        if value is not None:
493 491
             # MySQL will throw a warning if microseconds are given, because it
494 492
             # doesn't support microseconds.
495 493
             if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'):
496 494
                 value = value.replace(microsecond=0)
497 495
             value = str(value)
498  
-        elif isinstance(value, datetime.date):
499  
-            # MySQL will throw a warning if microseconds are given, because it
500  
-            # doesn't support microseconds.
501  
-            if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'):
502  
-                value = datetime.datetime(value.year, value.month, value.day, microsecond=0)
503  
-            value = str(value)
504  
-            
505 496
         return Field.get_db_prep_save(self, value)
506 497
 
507 498
     def get_db_prep_lookup(self, lookup_type, value):

0 notes on commit 95d1938

Please sign in to comment.
Something went wrong with that request. Please try again.