From 267523e4da6a6575fae507eabd003e975fc7094f Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 20 Dec 2007 01:45:36 +0000 Subject: - sqlite SLDate type will not erroneously render "microseconds" portion of a datetime or time object when sent to the DB. --- lib/sqlalchemy/databases/sqlite.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/databases/sqlite.py') diff --git a/lib/sqlalchemy/databases/sqlite.py b/lib/sqlalchemy/databases/sqlite.py index e028b1c53..0d673e9ab 100644 --- a/lib/sqlalchemy/databases/sqlite.py +++ b/lib/sqlalchemy/databases/sqlite.py @@ -50,7 +50,7 @@ class DateTimeMixin(object): # pass string values thru return value elif value is not None: - if getattr(value, 'microsecond', None) is not None: + if self.__microsecond__ and getattr(value, 'microsecond', None) is not None: return value.strftime(self.__format__ + "." + str(value.microsecond)) else: return value.strftime(self.__format__) @@ -70,6 +70,7 @@ class DateTimeMixin(object): class SLDateTime(DateTimeMixin,sqltypes.DateTime): __format__ = "%Y-%m-%d %H:%M:%S" + __microsecond__ = True def get_col_spec(self): return "TIMESTAMP" @@ -82,6 +83,7 @@ class SLDateTime(DateTimeMixin,sqltypes.DateTime): class SLDate(DateTimeMixin, sqltypes.Date): __format__ = "%Y-%m-%d" + __microsecond__ = False def get_col_spec(self): return "DATE" @@ -94,6 +96,7 @@ class SLDate(DateTimeMixin, sqltypes.Date): class SLTime(DateTimeMixin, sqltypes.Time): __format__ = "%H:%M:%S" + __microsecond__ = True def get_col_spec(self): return "TIME" -- cgit v1.2.1