summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/databases/postgres.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-10-14 19:15:09 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-10-14 19:15:09 +0000
commit5b92c3d097b487001c4152715a22c4de87fad871 (patch)
treeda65ceee13d4d76c05ef5b578a144981219b979d /lib/sqlalchemy/databases/postgres.py
parent79dafdf3d4ffe9cb56ee0b03651b92e7e7b7353e (diff)
downloadsqlalchemy-5b92c3d097b487001c4152715a22c4de87fad871.tar.gz
- PG reflection, upon seeing the default schema name being used explicitly
as the "schema" argument in a Table, will assume that this is the the user's desired convention, and will explicitly set the "schema" argument in foreign-key-related reflected tables, thus making them match only with Table constructors that also use the explicit "schema" argument (even though its the default schema). In other words, SA assumes the user is being consistent in this usage.
Diffstat (limited to 'lib/sqlalchemy/databases/postgres.py')
-rw-r--r--lib/sqlalchemy/databases/postgres.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py
index d894b1f2c..ddf6a6b9c 100644
--- a/lib/sqlalchemy/databases/postgres.py
+++ b/lib/sqlalchemy/databases/postgres.py
@@ -545,6 +545,11 @@ class PGDialect(default.DefaultDialect):
constrained_columns = [preparer._unquote_identifier(x) for x in re.split(r'\s*,\s*', constrained_columns)]
if referred_schema:
referred_schema = preparer._unquote_identifier(referred_schema)
+ elif table.schema is not None and table.schema == self.get_default_schema_name(connection):
+ # no schema (i.e. its the default schema), and the table we're
+ # reflecting has the default schema explicit, then use that.
+ # i.e. try to use the user's conventions
+ referred_schema = table.schema
referred_table = preparer._unquote_identifier(referred_table)
referred_columns = [preparer._unquote_identifier(x) for x in re.split(r'\s*,\s', referred_columns)]