diff options
| author | Daniel Wiesmann <daniel.wiesmann@gmail.com> | 2015-06-19 16:46:03 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-06-19 14:36:43 -0400 |
| commit | b769bbd4f6a3cd1bcd9ebf3559ec6ea0f9b50565 (patch) | |
| tree | 48cb987ced74d60f75fd86306edc2f87c764362f /django/db | |
| parent | d3d66d47222dd8765a20a15fdc754c0ed7635404 (diff) | |
Fixed #23804 -- Added RasterField for PostGIS.
Thanks to Tim Graham and Claude Paroz for the reviews and patches.
Diffstat (limited to 'django/db')
| -rw-r--r-- | django/db/backends/postgresql_psycopg2/introspection.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/django/db/backends/postgresql_psycopg2/introspection.py b/django/db/backends/postgresql_psycopg2/introspection.py index 32c69bc510..9b3e9074b2 100644 --- a/django/db/backends/postgresql_psycopg2/introspection.py +++ b/django/db/backends/postgresql_psycopg2/introspection.py @@ -34,6 +34,16 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): ignored_tables = [] + _get_indexes_query = """ + SELECT attr.attname, idx.indkey, idx.indisunique, idx.indisprimary + FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, + pg_catalog.pg_index idx, pg_catalog.pg_attribute attr + WHERE c.oid = idx.indrelid + AND idx.indexrelid = c2.oid + AND attr.attrelid = c.oid + AND attr.attnum = idx.indkey[0] + AND c.relname = %s""" + def get_field_type(self, data_type, description): field_type = super(DatabaseIntrospection, self).get_field_type(data_type, description) if field_type == 'IntegerField' and description.default and 'nextval' in description.default: @@ -108,15 +118,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): def get_indexes(self, cursor, table_name): # This query retrieves each index on the given table, including the # first associated field name - cursor.execute(""" - SELECT attr.attname, idx.indkey, idx.indisunique, idx.indisprimary - FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, - pg_catalog.pg_index idx, pg_catalog.pg_attribute attr - WHERE c.oid = idx.indrelid - AND idx.indexrelid = c2.oid - AND attr.attrelid = c.oid - AND attr.attnum = idx.indkey[0] - AND c.relname = %s""", [table_name]) + cursor.execute(self._get_indexes_query, [table_name]) indexes = {} for row in cursor.fetchall(): # row[1] (idx.indkey) is stored in the DB as an array. It comes out as |
