Handle NULL dates, fixes #91.
This commit is contained in:
parent
fcbaf977c0
commit
f5535fa085
@ -72,11 +72,15 @@ def sqlite_datetime_fix():
|
|||||||
epoch = datetime(1970, 1, 1, 0, 0, 0)
|
epoch = datetime(1970, 1, 1, 0, 0, 0)
|
||||||
|
|
||||||
def process_bind_param(self, value, dialect):
|
def process_bind_param(self, value, dialect):
|
||||||
|
if value is None:
|
||||||
|
return None
|
||||||
if isinstance(value, datetime):
|
if isinstance(value, datetime):
|
||||||
return value
|
return value
|
||||||
return (value / 1000 - self.epoch).total_seconds()
|
return (value / 1000 - self.epoch).total_seconds()
|
||||||
|
|
||||||
def process_result_value(self, value, dialect):
|
def process_result_value(self, value, dialect):
|
||||||
|
if value is None:
|
||||||
|
return None
|
||||||
if isinstance(value, int):
|
if isinstance(value, int):
|
||||||
return self.epoch + timedelta(seconds=value / 1000)
|
return self.epoch + timedelta(seconds=value / 1000)
|
||||||
return value
|
return value
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user