]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- fix to reflection on older DB's that might return array() type for
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 25 Jan 2007 01:37:15 +0000 (01:37 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 25 Jan 2007 01:37:15 +0000 (01:37 +0000)
"show variables like" statements

CHANGES
lib/sqlalchemy/databases/mysql.py

diff --git a/CHANGES b/CHANGES
index 32945649a79a90717767cb24ca5f7c5942a4552d..dc47d4978741082015832d3486ff8b7be9554f4b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -10,6 +10,9 @@
   table PK if not applicable, i.e. for a UNION.  checking for DISTINCT, GROUP BY
   (other places that rowid is invalid) still a TODO.  allows polymorphic mappings
   to function, [ticket:436]
+- mysql:
+  - fix to reflection on older DB's that might return array() type for 
+  "show variables like" statements
 
 0.3.4
 - general:
index aee26a405d6cad6cd72c2fcc80f2f753a03cf13a..d30751fb4def07b5f60560ed3bc0e1654281a548 100644 (file)
@@ -10,6 +10,7 @@ from sqlalchemy import sql,engine,schema,ansisql
 from sqlalchemy.engine import default
 import sqlalchemy.types as sqltypes
 import sqlalchemy.exceptions as exceptions
+from array import array
 
 try:
     import MySQLdb as mysql
@@ -338,7 +339,11 @@ class MySQLDialect(ansisql.ANSIDialect):
 
     def reflecttable(self, connection, table):
         # reference:  http://dev.mysql.com/doc/refman/5.0/en/name-case-sensitivity.html
-        case_sensitive = int(connection.execute("show variables like 'lower_case_table_names'").fetchone()[1]) == 0
+        cs = connection.execute("show variables like 'lower_case_table_names'").fetchone()[1]
+        if isinstance(cs, array):
+            cs = cs.tostring()
+        case_sensitive = int(cs) == 0
+        
         if not case_sensitive:
             table.name = table.name.lower()
             table.metadata.tables[table.name]= table