diff options
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) |