1. Thomas Hoffbauer
  2. django-mssql

Commits

Michael Manfre  committed 612cf9f

datetime.time values will convert to datetime.min + time going to the database and a datetime.time will be returned when reading from the database.

  • Participants
  • Parent commits a6ca2b8
  • Branches default

Comments (0)

Files changed (2)

File sqlserver_ado/compiler.py

View file
  • Ignore whitespace
             internal_type = field.get_internal_type()
             if internal_type == 'DateField' and isinstance(value, datetime.datetime):
                 new_row.append(value.date())
+            elif internal_type == 'TimeField' and isinstance(value, datetime.datetime):
+                new_row.append(value.time())    
             else:
                 new_row.append(value)
         return new_row

File sqlserver_ado/dbapi.py

View file
  • Ignore whitespace
             p.NumericScale = 0
             p.Precision = digit_count + exponent
 
+    elif isinstance(value, datetime.time):
+            p.Value = datetime.datetime(1,1,1, value.hour, value.minute, value.second)
     else:
         # For any other type, set the value and let pythoncom do the right thing.
         p.Value = value
             try:
                 _configure_parameter(p, value)
                 self.cmd.Parameters.Append(p)
-            except:
+            except Exception as e:
                 _message = u'Converting Parameter %s: %s, %s\n' %\
                     (p.Name, ado_type_name(p.Type), repr(value))