diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-01-28 23:40:34 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-01-28 23:40:34 +0000 |
commit | 9e47517f4876da8d5af34d29f58b9ea59da98d8f (patch) | |
tree | 56a77fa40b743de5cbfd07b9f8c40be79b4601fa | |
parent | bbc5e7c285a160f148eafa0ab442675fe88551ce (diff) | |
download | sqlalchemy-9e47517f4876da8d5af34d29f58b9ea59da98d8f.tar.gz |
added regexp search for "schema" in sequence reflection for [ticket:442], courtesy david.mugnai@spacespa.it
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/postgres.py | 6 |
2 files changed, 8 insertions, 0 deletions
@@ -22,6 +22,8 @@ - mysql: - fix to reflection on older DB's that might return array() type for "show variables like" statements +- postgres: + - better reflection of sequences for alternate-schema Tables [ticket:442] 0.3.4 - general: 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)) |