From: Jonathan Ellis Date: Thu, 27 Jul 2006 04:56:15 +0000 (+0000) Subject: PassiveDefault('?') for autoloaded sqlite defaults X-Git-Tag: rel_0_2_7~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c316c681726d3a5752162fe4aa33f858b774b4a;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git PassiveDefault('?') for autoloaded sqlite defaults (no complaints on-list so I'm checking this in... go ahead and revert if I'm stepping on any toes here, Mike) --- diff --git a/lib/sqlalchemy/databases/sqlite.py b/lib/sqlalchemy/databases/sqlite.py index c681f391ad..361705b716 100644 --- a/lib/sqlalchemy/databases/sqlite.py +++ b/lib/sqlalchemy/databases/sqlite.py @@ -7,7 +7,7 @@ import sys, StringIO, string, types, re -from sqlalchemy import sql, engine, schema, ansisql, exceptions, pool +from sqlalchemy import sql, engine, schema, ansisql, exceptions, pool, PassiveDefault import sqlalchemy.engine.default as default import sqlalchemy.types as sqltypes import datetime,time @@ -178,7 +178,7 @@ class SQLiteDialect(ansisql.ANSIDialect): break #print "row! " + repr(row) found_table = True - (name, type, nullable, primary_key) = (row[1], row[2].upper(), not row[3], row[5]) + (name, type, nullable, has_default, primary_key) = (row[1], row[2].upper(), not row[3], row[4], row[5]) match = re.match(r'(\w+)(\(.*?\))?', type) coltype = match.group(1) @@ -190,7 +190,11 @@ class SQLiteDialect(ansisql.ANSIDialect): args = re.findall(r'(\d+)', args) #print "args! " +repr(args) coltype = coltype(*[int(a) for a in args]) - table.append_item(schema.Column(name, coltype, primary_key = primary_key, nullable = nullable)) + + colargs= [] + if has_default: + colargs.append(PassiveDefault('?')) + table.append_item(schema.Column(name, coltype, primary_key = primary_key, nullable = nullable, *colargs)) if not found_table: raise exceptions.NoSuchTableError(table.name)