Skip to content

Commit

Permalink
[1.6.x] Fixed #20829 -- Skip postgis metadata tables with introspection
Browse files Browse the repository at this point in the history
Backport of 2408861 from master.
  • Loading branch information
Urth authored and claudep committed Aug 16, 2013
1 parent 1b48de0 commit a6ac4f9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions django/contrib/gis/db/backends/postgis/introspection.py
Expand Up @@ -9,6 +9,14 @@ class PostGISIntrospection(DatabaseIntrospection):
# introspection is actually performed. # introspection is actually performed.
postgis_types_reverse = {} postgis_types_reverse = {}


ignored_tables = DatabaseIntrospection.ignored_tables + [
'geography_columns',
'geometry_columns',
'raster_columns',
'spatial_ref_sys',
'raster_overviews',
]

def get_postgis_types(self): def get_postgis_types(self):
""" """
Returns a dictionary with keys that are the PostgreSQL object Returns a dictionary with keys that are the PostgreSQL object
Expand Down
6 changes: 4 additions & 2 deletions django/db/backends/postgresql_psycopg2/introspection.py
Expand Up @@ -25,7 +25,9 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
1266: 'TimeField', 1266: 'TimeField',
1700: 'DecimalField', 1700: 'DecimalField',
} }


ignored_tables = []

def get_table_list(self, cursor): def get_table_list(self, cursor):
"Returns a list of table names in the current database." "Returns a list of table names in the current database."
cursor.execute(""" cursor.execute("""
Expand All @@ -35,7 +37,7 @@ def get_table_list(self, cursor):
WHERE c.relkind IN ('r', 'v', '') WHERE c.relkind IN ('r', 'v', '')
AND n.nspname NOT IN ('pg_catalog', 'pg_toast') AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
AND pg_catalog.pg_table_is_visible(c.oid)""") AND pg_catalog.pg_table_is_visible(c.oid)""")
return [row[0] for row in cursor.fetchall()] return [row[0] for row in cursor.fetchall() if row[0] not in self.ignored_tables]


def get_table_description(self, cursor, table_name): def get_table_description(self, cursor, table_name):
"Returns a description of the table, with the DB-API cursor.description interface." "Returns a description of the table, with the DB-API cursor.description interface."
Expand Down

0 comments on commit a6ac4f9

Please sign in to comment.