summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/base.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-02-14 14:32:00 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-02-14 14:32:00 -0500
commitffa6f45ec392bdffd419484e1343c7853433d9c4 (patch)
treec6ef8a181faa156c51dd4d375537e17be4ba3095 /lib/sqlalchemy/dialects/postgresql/base.py
parent3e7caad3cfe6797e9a7a89394cf946abc43db706 (diff)
downloadsqlalchemy-ffa6f45ec392bdffd419484e1343c7853433d9c4.tar.gz
- Revised this very old issue where the Postgresql "get primary key"
reflection query were updated to take into account primary key constraints that were renamed; the newer query fails on very old versions of Postgresql such as version 7, so the old query is restored in those cases when server_version_info < (8, 0) is detected. #2291
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 29584d1eb..1b5927dbd 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -2026,7 +2026,21 @@ class PGDialect(default.DefaultDialect):
table_oid = self.get_table_oid(connection, table_name, schema,
info_cache=kw.get('info_cache'))
- if self.server_version_info < (8, 4):
+ if self.server_version_info < (8, 0):
+ # the shortcoming of this query is that it will
+ # not detect a PK constraint that has been renamed.
+ # This query was removed with #2291, however it was reported
+ # that the newer queries do not work with PG 7 so here
+ # it is restored when old PG versions are detected.
+ PK_SQL = """
+ SELECT attname FROM pg_attribute
+ WHERE attrelid = (
+ SELECT indexrelid FROM pg_index i
+ WHERE i.indrelid = :table_oid
+ AND i.indisprimary = 't')
+ ORDER BY attnum
+ """
+ elif self.server_version_info < (8, 4):
# unnest() and generate_subscripts() both introduced in
# version 8.4
PK_SQL = """