Skip to content

Commit

Permalink
Changing default TDS version & TDS version handling
Browse files Browse the repository at this point in the history
7.1 should work for most things
7.2 is incomplete and some of the more significant features in 7.2
    are supported in 7.1
8.0 is really 7.1

http://www.freetds.org/userguide/choosingtdsprotocol.htm
http://lists.ibiblio.org/pipermail/freetds/2011q3/027303.html
  • Loading branch information
rsyring committed Oct 17, 2011
1 parent 6c249c3 commit ba0ac4d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion _mssql.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ cdef class MSSQLConnection:
self.column_types = None

def __init__(self, server="localhost", user="sa", password="",
charset='', database='', appname=None, port='1433', tds_version='8.0'):
charset='', database='', appname=None, port='1433', tds_version='7.1'):
log("_mssql.MSSQLConnection.__init__()")

cdef LOGINREC *login
Expand Down Expand Up @@ -1430,6 +1430,10 @@ cdef int _tds_ver_str_to_constant(bytes verstr) except -1:
return DBVERSION_42
if verstr == u'7.0':
return DBVERSION_70
if verstr == u'7.1':
return DBVERSION_71
if verstr == u'7.2':
return DBVERSION_72
if verstr == u'8.0':
return DBVERSION_80
raise MSSQLException('unrecognized tds version: %s' % verstr)
Expand Down
2 changes: 2 additions & 0 deletions sqlfront.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ cdef extern from "sqlfront.h":
## Version Constants ##
int DBVERSION_42
int DBVERSION_70
int DBVERSION_71
int DBVERSION_72
int DBVERSION_80

## Type Constants ##
Expand Down
5 changes: 5 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ def test_tds_protocal_version_70(self):
assert 'major_version = 7' in config_dump
assert 'minor_version = 0' in config_dump

def test_tds_protocal_version_71(self):
config_dump = self.connect(tds_version='7.1')
assert 'major_version = 7' in config_dump
assert 'minor_version = 1' in config_dump

def test_tds_protocal_version_80(self):
# follow-up: turns out 8.0 was erroneous. MS named the new protocal
# 7.1 instead of 8.0, so FreeTDS will accept 8.0 but shows as 7.1.
Expand Down

0 comments on commit ba0ac4d

Please sign in to comment.