summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/base.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2018-10-01 16:23:33 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2018-10-01 16:24:55 -0400
commitf1ca155cea10e32fec3dfe9fdae6674ee81c0ef4 (patch)
treebe3985ecd220d43724654991aa1c0b46a7c9f3e7 /lib/sqlalchemy/dialects/postgresql/base.py
parent29d54ab69b689c2bc4b9be8273f4c0a96e37153f (diff)
downloadsqlalchemy-f1ca155cea10e32fec3dfe9fdae6674ee81c0ef4.tar.gz
Add reflection support for Postgresql partitioned tables
Added rudimental support for reflection of Postgresql partitioned tables, e.g. that relkind='p' is added to reflection queries that return table information. Fixes: #4237 Change-Id: I66fd10b002e4ed21ea13b13a7e35a85f66bdea75
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index ea2c51870..11fcc41d5 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -2460,7 +2460,8 @@ class PGDialect(default.DefaultDialect):
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE (%s)
- AND c.relname = :table_name AND c.relkind in ('r', 'v', 'm', 'f')
+ AND c.relname = :table_name AND c.relkind in
+ ('r', 'v', 'm', 'f', 'p')
""" % schema_where_clause
# Since we're binding to unicode, table_name and schema_name must be
# unicode.
@@ -2491,7 +2492,7 @@ class PGDialect(default.DefaultDialect):
result = connection.execute(
sql.text("SELECT c.relname FROM pg_class c "
"JOIN pg_namespace n ON n.oid = c.relnamespace "
- "WHERE n.nspname = :schema AND c.relkind = 'r'"
+ "WHERE n.nspname = :schema AND c.relkind in ('r', 'p')"
).columns(relname=sqltypes.Unicode),
schema=schema if schema is not None else self.default_schema_name)
return [name for name, in result]