MSDate, MSTime completely broken for pyodbc
There is no test coverage for the MSSQL DATE
or TIME
type at all. the server_version_info
attribute is incorrectly used here:
if self.server_version_info < (10,):
self.colspecs = MSSQLDialect.colspecs.copy()
self.ischema_names = MSSQLDialect.ischema_names.copy()
self.ischema_names['date']('date') = MSDateTimeAsDate
self.colspecs[sqltypes.Date](sqltypes.Date) = MSDateTimeAsDate
self.ischema_names['time']('time') = MSDateTimeAsTime
self.colspecs[sqltypes.Time](sqltypes.Time) = MSDateTimeAsTime
server_version_info
is a method requiring a connection, so the above always takes place, and MSDateTimeAsDate/Time
are always used - DDL for DATE
and TIME
is never issued.
So removing the code above allows the tests in testtypes.py
to actually create DATE
and TIME
columns. You need to use the same bind parameter processing on MSDate
and MSTime
as that of MSDateTimeAsDate
, etc. For result processing, pyodbc returns a string for each of DATE and TIME:
Row (7, 'jack', datetime.datetime(2005, 11, 10, 0, 0), u'2005-11-10', u'12
:20:02.0000000')
Row (8, 'roy', datetime.datetime(2005, 11, 10, 0, 0), u'2005-10-10', u'00:
00:00.0000000')
Row (9, 'foo', datetime.datetime(2005, 11, 10, 0, 0), u'1970-04-01', u'23:
59:59.0000000')
So the MSDate
and MSTime
types require string parsing on the result side in order to function properly. tested with MS2008 and the latest pyodbc.
I'm not even sure if I want to target this for 0.5, and for 0.6 I think we might want to table ADODBAPI and PYMSSQL support completely since I don't have the bandwidth to address all three DBAPIs.
Comments (8)
-
reporter -
reporter and the reason its tough for 0.5 is because I've standardized server_version in the 0.6 dialect. 0.5 has no convenient way to get at this information and it might not be worth building around it.
-
Account Deleted (original author: ram) do those new types work on unix over odbc/freetds? I assumed that these would only work with a new tds driver of version 10 (every release of mssql usually brings a new access protocol too).
-
What other test coverage are you looking for? http://www.sqlalchemy.org/trac/browser/sqlalchemy/trunk/test/dialect/mssql.py#L645
-
Account Deleted (original author: ram) No complaints about the tests themselves, just wondering if you had tried them on a Unix OS over FreeTDS. It's unclear if the new datatypes are supported by the current FreeTDS driver.
-
Ah, okay. No I have not tried them on Unix OS over FreeTDS. I follow you now, thanks.
-
I have no problem with these types on FreeTDS to PyODBC on 0.6. If you're still seeing a problem provide a test case and we'll investigate.
-
reporter - removed milestone
Removing milestone: 0.6.0 (automated comment)
- Log in to comment
15495de0edce3aa232991e97986b0a70f4107caa has them working in the 0.6 branch.