From a38cc03bb6e114fe846704600aaf0b4ee6023422 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 7 Aug 2006 21:58:53 +0000 Subject: [PATCH] fixed possible error in mysql reflection where certain versions return an array instead of string for SHOW CREATE TABLE call --- CHANGES | 2 ++ lib/sqlalchemy/databases/mysql.py | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 36c27d6cc2..83ea698d83 100644 --- 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 diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py index c98593a55d..7e337b9a35 100644 --- a/lib/sqlalchemy/databases/mysql.py +++ b/lib/sqlalchemy/databases/mysql.py @@ -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: -- 2.47.2