]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
ticket 298 plus transaction fixes for pymssql
authorRick Morrison <rickmorrison@gmail.com>
Tue, 6 Feb 2007 20:04:09 +0000 (20:04 +0000)
committerRick Morrison <rickmorrison@gmail.com>
Tue, 6 Feb 2007 20:04:09 +0000 (20:04 +0000)
CHANGES
lib/sqlalchemy/databases/mssql.py
lib/sqlalchemy/exceptions.py

diff --git a/CHANGES b/CHANGES
index 9aab59481e1a47ef4c2a44206191f53632e59ebe..2aa1ff228105b3e6a9e73caaadf02212a77282e1 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -44,6 +44,9 @@
 - ext:
   - added distinct() method to SelectResults.  generally should only make a difference
   when using count().
+- mssql:
+  - better support for NVARCHAR types added [ticket:298]
+  - fix for commit logic on pymssql
   
 0.3.4
 - general:
index fbb89de1ab3f9b3c1366ace2f0cea5d2f9396f21..04b949d6ad3f51fd44379352ddfcdac4a348a013 100644 (file)
@@ -146,13 +146,28 @@ class MSText(sqltypes.TEXT):
 class MSString(sqltypes.String):
     def get_col_spec(self):
         return "VARCHAR(%(length)s)" % {'length' : self.length}
+
+
 class MSNVarchar(MSString):
     """NVARCHAR string, does unicode conversion if dialect.convert_encoding is true"""
+    impl = sqltypes.Unicode
     def get_col_spec(self):
         return "NVARCHAR(%(length)s)" % {'length' : self.length}
+    if dbmodule and dbmodule.__name__ == 'adodbapi':
+        def convert_bind_param(self, value, dialect):
+            return value
+        def convert_result_value(self, value, dialect):
+            return value        
+
 class MSUnicode(sqltypes.Unicode):
     """Unicode subclass, does unicode conversion in all cases, uses NVARCHAR impl"""
     impl = MSNVarchar
+    if dbmodule and dbmodule.__name__ == 'adodbapi':
+        def convert_bind_param(self, value, dialect):
+            return value
+        def convert_result_value(self, value, dialect):
+            return value        
+
 class MSChar(sqltypes.CHAR):
     def get_col_spec(self):
         return "CHAR(%(length)s)" % {'length' : self.length}
@@ -264,10 +279,10 @@ class MSSQLExecutionContext(default.DefaultExecutionContext):
 
 
 class MSSQLDialect(ansisql.ANSIDialect):
-    def __init__(self, module=None, auto_identity_insert=False, **params):
+    def __init__(self, module=None, auto_identity_insert=False, encoding=None, **params):
         self.module = module or dbmodule
         self.auto_identity_insert = auto_identity_insert
-        ansisql.ANSIDialect.__init__(self, **params)
+        ansisql.ANSIDialect.__init__(self, encoding=encoding, **params)
         self.set_default_schema_name("dbo")
         
     def create_connect_args(self, url):
@@ -468,8 +483,7 @@ class MSSQLDialect(ansisql.ANSIDialect):
 class PyMSSQLDialect(MSSQLDialect):
     def do_begin(self, connection):
         """implementations might want to put logic here for turning autocommit on/off, etc."""
-        if do_commit:
-            pass  
+        pass  
 
     def do_rollback(self, connection):
         """implementations might want to put logic here for turning autocommit on/off, etc."""
@@ -497,7 +511,6 @@ class PyMSSQLDialect(MSSQLDialect):
         r.query("begin tran")
         r.fetch_array()
 
-
 class MSSQLCompiler(ansisql.ANSICompiler):
     def __init__(self, dialect, statement, parameters, **kwargs):
         super(MSSQLCompiler, self).__init__(dialect, statement, parameters, **kwargs)
@@ -544,7 +557,6 @@ class MSSQLCompiler(ansisql.ANSICompiler):
             self.strings[column] = \
                 self.strings[self.tablealiases[column.table].corresponding_column(column)]
 
-        
 class MSSQLSchemaGenerator(ansisql.ANSISchemaGenerator):
     def get_column_specification(self, column, **kwargs):
         colspec = self.preparer.format_column(column) + " " + column.type.engine_impl(self.engine).get_col_spec()
index 930aa8ea368dd6acc87d88c7c1192f4e0cadf2d5..1caee06494d8dcf0c482e497755d3f1647fd20b2 100644 (file)
@@ -60,3 +60,8 @@ class DBAPIError(SQLAlchemyError):
     def __init__(self, message, orig):
         SQLAlchemyError.__init__(self, "(%s) (%s) %s"% (message, orig.__class__.__name__, str(orig)))
         self.orig = orig
+
+class MissingTypeError(SQLAlchemyError):
+    """no database type is available for the sa type"""
+    pass
+