]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- some tweaks to try to help out mssql+pyodbc support a bit, py3k is really
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 3 Jun 2013 16:54:56 +0000 (12:54 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 3 Jun 2013 16:54:56 +0000 (12:54 -0400)
not happening too well (I need to stick with linux + freetds 0.91, I know)

lib/sqlalchemy/connectors/pyodbc.py
lib/sqlalchemy/dialects/mssql/base.py
setup.cfg
test/sql/test_query.py

index 784344b824e56109ee2f8993268ef7e74c858866..6b4e3036da1a332c98bfe7673baa43836942ca12 100644 (file)
@@ -16,9 +16,12 @@ class PyODBCConnector(Connector):
     driver = 'pyodbc'
 
     supports_sane_multi_rowcount = False
-    # PyODBC unicode is broken on UCS-4 builds
-    supports_unicode = sys.maxunicode == 65535
-    supports_unicode_statements = supports_unicode
+
+    if util.py2k:
+        # PyODBC unicode is broken on UCS-4 builds
+        supports_unicode = sys.maxunicode == 65535
+        supports_unicode_statements = supports_unicode
+
     supports_native_decimal = True
     default_paramstyle = 'named'
 
@@ -121,15 +124,19 @@ class PyODBCConnector(Connector):
             self.freetds_driver_version = dbapi_con.getinfo(
                 pyodbc.SQL_DRIVER_VER)
 
-        if not util.py3k:
-            self.supports_unicode_statements = (
-                not self.freetds and not self.easysoft)
-            if self._user_supports_unicode_binds is not None:
-                self.supports_unicode_binds = self._user_supports_unicode_binds
-            else:
-                self.supports_unicode_binds = (
-                    not self.freetds or self.freetds_driver_version >= '0.91'
-                ) and not self.easysoft
+        self.supports_unicode_statements = (
+            not util.py2k or
+            (not self.freetds and not self.easysoft)
+        )
+
+        if self._user_supports_unicode_binds is not None:
+            self.supports_unicode_binds = self._user_supports_unicode_binds
+        elif util.py2k:
+            self.supports_unicode_binds = (
+                not self.freetds or self.freetds_driver_version >= '0.91'
+            ) and not self.easysoft
+        else:
+            self.supports_unicode_binds = True
 
         # run other initialization which asks for user name, etc.
         super(PyODBCConnector, self).initialize(connection)
index a5d789be19150db5f9dac838529e030155bc70ba..3c329fe5e50b2277749b2ba62d9c62be79a34f40 100644 (file)
@@ -1172,6 +1172,7 @@ class MSDialect(default.DefaultDialect):
         columns = ischema.columns
 
         whereclause = self._unicode_cast(columns.c.table_name) == tablename
+
         if owner:
             whereclause = sql.and_(whereclause,
                                    columns.c.table_schema == owner)
index 9c53e32ad1742c5ae56d7128d1ceff310c4b1dfb..61c868a1634d9f567380a2dddd05985dd29264a6 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -32,6 +32,7 @@ pg8000=postgresql+pg8000://scott:tiger@127.0.0.1:5432/test
 postgresql_jython=postgresql+zxjdbc://scott:tiger@127.0.0.1:5432/test
 mysql_jython=mysql+zxjdbc://scott:tiger@127.0.0.1:5432/test
 mysql=mysql://scott:tiger@127.0.0.1:3306/test
+mssql=mssql+pyodbc://scott:tiger@ms_2005
 oursql=mysql+oursql://scott:tiger@127.0.0.1:3306/test
 pymysql=mysql+pymysql://scott:tiger@127.0.0.1:3306/test?use_unicode=0&charset=utf8
 oracle=oracle://scott:tiger@127.0.0.1:1521
index 3e9045fa56a51273e086c3470ce03ce266880963..ae029b11ca8849d1e4bccb7415ebc537f2e68d04 100644 (file)
@@ -708,8 +708,6 @@ class QueryTest(fixtures.TestBase):
                               use_labels=labels),
                  [(3, 'a'), (2, 'b'), (1, None)])
 
-    @testing.fails_on('mssql+pyodbc',
-        "pyodbc result row doesn't support slicing")
     def test_column_slices(self):
         users.insert().execute(user_id=1, user_name='john')
         users.insert().execute(user_id=2, user_name='jack')