diff options
author | Nick Pope <nick.pope@flightdataservices.com> | 2018-09-12 21:53:24 +0100 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2018-11-19 14:06:01 -0500 |
commit | ebd270627c3350101959fac59650259f2d33efcf (patch) | |
tree | 039d6f112d175f729e6fd75db81f5c700546333f /django/db/backends/postgresql/introspection.py | |
parent | 06076999026091cf007d8ea69146340a361259f8 (diff) | |
download | django-ebd270627c3350101959fac59650259f2d33efcf.tar.gz |
Refs #29722 -- Added introspection of partitions for PostgreSQL.
Diffstat (limited to 'django/db/backends/postgresql/introspection.py')
-rw-r--r-- | django/db/backends/postgresql/introspection.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/django/db/backends/postgresql/introspection.py b/django/db/backends/postgresql/introspection.py index 85538262cb..3ce88ccfbf 100644 --- a/django/db/backends/postgresql/introspection.py +++ b/django/db/backends/postgresql/introspection.py @@ -42,18 +42,15 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): def get_table_list(self, cursor): """Return a list of table and view names in the current database.""" cursor.execute(""" - SELECT c.relname, c.relkind + SELECT c.relname, + CASE WHEN {} THEN 'p' WHEN c.relkind IN ('m', 'v') THEN 'v' ELSE 't' END FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace - WHERE c.relkind IN ('f', 'm', 'r', 'v') + WHERE c.relkind IN ('f', 'm', 'p', 'r', 'v') AND n.nspname NOT IN ('pg_catalog', 'pg_toast') AND pg_catalog.pg_table_is_visible(c.oid) - """) - mapping = {'f': 't', 'm': 'v', 'r': 't', 'v': 'v'} - return [ - TableInfo(row[0], mapping[row[1]]) - for row in cursor.fetchall() if row[0] not in self.ignored_tables - ] + """.format('c.relispartition' if self.connection.features.supports_table_partitions else 'FALSE')) + return [TableInfo(*row) for row in cursor.fetchall() if row[0] not in self.ignored_tables] def get_table_description(self, cursor, table_name): """ @@ -73,7 +70,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): JOIN pg_type t ON a.atttypid = t.oid JOIN pg_class c ON a.attrelid = c.oid JOIN pg_namespace n ON c.relnamespace = n.oid - WHERE c.relkind IN ('f', 'm', 'r', 'v') + WHERE c.relkind IN ('f', 'm', 'p', 'r', 'v') AND c.relname = %s AND n.nspname NOT IN ('pg_catalog', 'pg_toast') AND pg_catalog.pg_table_is_visible(c.oid) |