]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fixed possible error in mysql reflection where certain versions
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 7 Aug 2006 21:58:53 +0000 (21:58 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 7 Aug 2006 21:58:53 +0000 (21:58 +0000)
return an array instead of string for SHOW CREATE TABLE call

CHANGES
lib/sqlalchemy/databases/mysql.py

diff --git a/CHANGES b/CHANGES
index 36c27d6cc2b371668434367e80334ccf0005a140..83ea698d8336a1b48c7710225295c58d8087ab07 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -23,6 +23,8 @@ succeeded.  added a test script to attempt testing this.
 only a given number of thread-local connections stay around (needed
 for sqlite applications that dispose of threads en masse)
 - fixed small pickle bug with lazy loaders [ticket:265]
+- fixed possible error in mysql reflection where certain versions
+return an array instead of string for SHOW CREATE TABLE call
 
 0.2.6
 - big overhaul to schema to allow truly composite primary and foreign
index c98593a55d5da778e6c5268f62a662ac395fcfbc..7e337b9a3571adf8ebed3d62ba2275d21a110023 100644 (file)
@@ -372,7 +372,12 @@ class MySQLDialect(ansisql.ANSIDialect):
         CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`) ON DELETE CASCADE\n) TYPE=InnoDB
         """
         c = connection.execute("SHOW CREATE TABLE " + table.name, {})
-        desc = c.fetchone()[1].strip()
+        desc_fetched = c.fetchone()[1]
+        if type(desc_fetched) is not str:
+            # may get array.array object here, depending on version (such as mysql 4.1.14 vs. 4.1.11)
+            desc_fetched = desc_fetched.tostring()
+        desc = desc_fetched.strip()
+
         tabletype = ''
         lastparen = re.search(r'\)[^\)]*\Z', desc)
         if lastparen: