From: Mike Bayer Date: Mon, 22 Jun 2009 21:27:10 +0000 (+0000) Subject: since we aren't using text() in the DefaultClause we reflect, we need to unquote... X-Git-Tag: rel_0_6_6~165 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3245ae578e8a9d0d7d38a12bd8287e2c61c6b555;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git since we aren't using text() in the DefaultClause we reflect, we need to unquote the incoming default from reflection. this is sqlite so far. not quite sure what will happen with other dialects yet. --- diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py index 2002115812..40c140569a 100644 --- a/lib/sqlalchemy/dialects/sqlite/base.py +++ b/lib/sqlalchemy/dialects/sqlite/base.py @@ -408,6 +408,8 @@ class SQLiteDialect(default.DefaultDialect): break (name, type_, nullable, default, has_default, primary_key) = (row[1], row[2].upper(), not row[3], row[4], row[4] is not None, row[5]) name = re.sub(r'^\"|\"$', '', name) + if default: + default = re.sub(r"^\'|\'$", '', default) match = re.match(r'(\w+)(\(.*?\))?', type_) if match: coltype = match.group(1) @@ -424,6 +426,7 @@ class SQLiteDialect(default.DefaultDialect): if args is not None: args = re.findall(r'(\d+)', args) coltype = coltype(*[int(a) for a in args]) + columns.append({ 'name' : name, 'type' : coltype, diff --git a/test/dialect/test_sqlite.py b/test/dialect/test_sqlite.py index a582251c1f..32f8a9e072 100644 --- a/test/dialect/test_sqlite.py +++ b/test/dialect/test_sqlite.py @@ -158,7 +158,7 @@ class TestDefaults(TestBase, AssertsExecutionResults): db = testing.db m = MetaData(db) - expected = ["'my_default'", '0'] + expected = ["my_default", '0'] table = """CREATE TABLE r_defaults ( data VARCHAR(40) DEFAULT 'my_default', val INTEGER NOT NULL DEFAULT 0