Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion commcare_export/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,10 @@ def best_type_for(self, val):
if isinstance(val, bool):
return sqlalchemy.Boolean()
elif isinstance(val, datetime.datetime):
return sqlalchemy.DateTime()
if self.is_mssql:
return sqlalchemy.dialects.mssql.DATETIME2()
else:
return sqlalchemy.DateTime()
elif isinstance(val, datetime.date):
return sqlalchemy.Date()

Expand Down
5 changes: 2 additions & 3 deletions tests/test_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,8 @@ def test_change_type(self, writer):
expected['bazzle']['c'] = '0'
if 'pyodbc' in writer.connection.engine.driver:
expected['bazzle']['c'] = '0'
# couldn't figure out how to make SQL Server convert date to ISO8601
# see https://docs.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-2017#date-and-time-styles
expected['bazzle']['e'] = 'May 1 2014 11:16AM'
# MSSQL includes fractional seconds in returned value.
expected['bazzle']['e'] = '2014-05-01 11:16:45.0000000'

for id, row in result.items():
assert id in expected
Expand Down