From 9e47517f4876da8d5af34d29f58b9ea59da98d8f Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 28 Jan 2007 23:40:34 +0000 Subject: added regexp search for "schema" in sequence reflection for [ticket:442], courtesy david.mugnai@spacespa.it --- lib/sqlalchemy/databases/postgres.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/sqlalchemy/databases/postgres.py') diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 7eee35320..3fea2e1a5 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -396,6 +396,12 @@ class PGDialect(ansisql.ANSIDialect): coltype = coltype(*args, **kwargs) colargs= [] if default is not None: + match = re.search(r"""(nextval\(')([^']+)('.*$)""", default) + if match is not None: + # the default is related to a Sequence + sch = table.schema + if '.' not in match.group(2) and sch is not None: + default = match.group(1) + sch + '.' + match.group(2) + match.group(3) colargs.append(PassiveDefault(sql.text(default))) table.append_column(schema.Column(name, coltype, nullable=nullable, *colargs)) -- cgit v1.2.1