]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
added "supports_unicode_statements()" step to dialect/execute_raw so that DB's like...
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 28 Mar 2007 15:53:18 +0000 (15:53 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 28 Mar 2007 15:53:18 +0000 (15:53 +0000)
lib/sqlalchemy/databases/oracle.py
lib/sqlalchemy/engine/base.py
lib/sqlalchemy/engine/default.py

index be53109a5c887804e50bbd0477e84736e7c3a77b..4633a0a8c9eb0e1d58fcb6df2293f49793e882e1 100644 (file)
@@ -193,6 +193,10 @@ class OracleDialect(ansisql.ANSIDialect):
     def type_descriptor(self, typeobj):
         return sqltypes.adapt_type(typeobj, colspecs)
 
+    def supports_unicode_statements(self):
+        """indicate whether the DBAPI can receive SQL statements as Python unicode strings"""
+        return False
+
     def max_identifier_length(self):
         return 30
         
index c2ae272f512a63417def67c3655f8368ffad860f..cf0d350358080c4670846c52a1cbcb280d7918aa 100644 (file)
@@ -111,6 +111,10 @@ class Dialect(sql.AbstractDialect):
         Return None if no limit."""
         return None
 
+    def supports_unicode_statements(self):
+        """indicate whether the DBAPI can receive SQL statements as Python unicode strings"""
+        raise NotImplementedError()
+        
     def supports_sane_rowcount(self):
         """Indicate whether the dialect properly implements statements rowcount.
 
@@ -544,6 +548,9 @@ class Connection(Connectable):
     def _execute_raw(self, statement, parameters=None, cursor=None, context=None, **kwargs):
         if cursor is None:
             cursor = self.__engine.dialect.create_cursor(self.connection)
+        if not self.__engine.dialect.supports_unicode_statements():
+            # encode to ascii, with full error handling
+            statement = statement.encode('ascii')
         self.__engine.logger.info(statement)
         self.__engine.logger.info(repr(parameters))
         if parameters is not None and isinstance(parameters, list) and len(parameters) > 0 and (isinstance(parameters[0], list) or isinstance(parameters[0], dict)):
index e9ea6c1498d3a635851c1eb0763e3dd6b12b6769..86563cd7cbcedfb5d4c6a876b9f57003bd5dba15 100644 (file)
@@ -48,6 +48,10 @@ class DefaultDialect(base.Dialect):
             typeobj = typeobj()
         return typeobj
 
+    def supports_unicode_statements(self):
+        """indicate whether the DBAPI can receive SQL statements as Python unicode strings"""
+        return True
+
     def max_identifier_length(self):
         # TODO: probably raise this and fill out
         # db modules better