Michael Manfre avatar Michael Manfre committed eb91d25

Fixed #14 - Default provider changed to 'SQLCLI10' with use_mars = True

Comments (0)

Files changed (4)

docs/changelog.txt

 
 - Ensure master connection connects to the correct database name when TEST_NAME is not defined.
 - Connection.close() will now reset adoConn to make sure it's gone before the CoUninitialize.
+- Changed provider default from 'SQLOLEDB' to 'SQLNCLI10' with MARS enabled.
 
 v1.1
 ----

docs/quickstart.txt

                 'HOST': 'dbserver\\ss2008',
                 'USER': '',
                 'PASSWORD': '',
-                'OPTIONS' : {
-                    'provider': 'SQLOLEDB',
-                    'use_mars': True,
-                },
             }
         }
 
     .. note:: Although the project is named ``django-mssql`` the python module is named ``sqlserver_ado``.
 
+
 Dependencies
 ------------
 

docs/settings.txt

             'HOST': 'dbserver\\ss2008',
             'USER': '',
             'PASSWORD': '',
-            'OPTIONS' : {
-                'provider': 'SQLOLEDB',
-                'use_mars': True,
-            },
         }
     }
 
 use_mars
 ~~~~~~~~
 
-Default: ``False``
+Default: ``True``
 
-Set to ``True`` to enable `Multiple Active Recordsets`. It is recommended 
-to enable MARS to avoid seeing the "Cannot create new connection because 
-in manual or distributed transaction mode" error.
+Set to ``False`` to disable `Multiple Active Recordsets`. It is not recommended 
+to disable MARS. Without MARS enabled, you will probably end up seeing the error
+"Cannot create new connection because in manual or distributed transaction mode".
 
 .. note::
-    This will only set the appropriate connection string value for 
-    the "SQLOLEDB" provider. If you are using a different provider, you 
-    will need to add the appropriate connection string value to 
-    `extra_params`_.
+    This doesn't really work properly with the "SQLOLEDB" provider.
 
 
 .. _`extra_params`: OPTIONS-EXTRA_PARAMS
 provider
 ~~~~~~~~
 
-Default: ``'SQLOLEDB'``
+Default: ``'SQLCLI10'``
 
-The SQL provider to use when connecting to the database.
+The SQL provider to use when connecting to the database. If this doesn't work, 
+try 'SQLCLI11' or 'SQLOLEDB'.
+
+.. note::
+    ``use_mars = True`` doesn't always work properly with 'SQLOLEDB' and can result in the error 
+    "Cannot create new connection because in manual or distributed transaction mode."
+    if you try to filter a queryset with another queryset.
 
 
 disable_avg_cast

sqlserver_ado/base.py

         auth_string = "Integrated Security=SSPI"
 
     parts = [
-        "PROVIDER=SQLOLEDB", 
         "DATA SOURCE=%s" % (db_host,),
         "Initial Catalog=%s" % (db_name,),
         auth_string
     ]
+
+    options = settings.OPTIONS
+
+    if not options.get('provider', None):
+        options['provider'] = 'sqlncli10'
     
-    options = settings.OPTIONS
-    if options:
-        if 'use_mars' in options and options['use_mars']:
-            parts.append("MARS Connection=True")
-            
-        if 'extra_params' in options:
-            parts.append(options['extra_params'])
+    parts.append('PROVIDER={0}'.format(options['provider']))
         
-        if 'provider' in options:
-            parts[0] = 'PROVIDER=%s' % (options['provider'],)
+    if options['provider'].lower().find('=sqlcli') != -1:
+        # native client needs a compatibility mode that behaves like OLEDB
+        parts.append('DataTypeCompatibility=80')
+
+    if options.get('use_mars', True):
+        parts.append('MARS Connection=True')
+    
+    if options.get('extra_params', None):
+        parts.append(options['extra_params'])    
     
     return ";".join(parts)
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.