summaryrefslogtreecommitdiff
path: root/django/db/backends/postgresql_psycopg2/creation.py
diff options
context:
space:
mode:
authorVlastimil Zíma <vlastimil.zima@nic.cz>2014-05-19 18:19:35 +0200
committerTim Graham <timograham@gmail.com>2014-06-20 11:59:02 -0400
commit78c32f1caa9cb9b28be2d867aff586a2016122ed (patch)
tree3a8449118905a66cad8324e1747523348a90835c /django/db/backends/postgresql_psycopg2/creation.py
parent9a46836a0c3e15021df242f3dd5a33306f7e27bc (diff)
downloaddjango-78c32f1caa9cb9b28be2d867aff586a2016122ed.tar.gz
Fixed #22514 -- Prevented indexes on virtual fields [postgres].
Diffstat (limited to 'django/db/backends/postgresql_psycopg2/creation.py')
-rw-r--r--django/db/backends/postgresql_psycopg2/creation.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/django/db/backends/postgresql_psycopg2/creation.py b/django/db/backends/postgresql_psycopg2/creation.py
index 2594ba1d5f..d363faaa82 100644
--- a/django/db/backends/postgresql_psycopg2/creation.py
+++ b/django/db/backends/postgresql_psycopg2/creation.py
@@ -47,7 +47,8 @@ class DatabaseCreation(BaseDatabaseCreation):
def sql_indexes_for_field(self, model, f, style):
output = []
- if f.db_index or f.unique:
+ db_type = f.db_type(connection=self.connection)
+ if db_type is not None and (f.db_index or f.unique):
qn = self.connection.ops.quote_name
db_table = model._meta.db_table
tablespace = f.db_tablespace or model._meta.db_tablespace
@@ -73,7 +74,6 @@ class DatabaseCreation(BaseDatabaseCreation):
# a second index that specifies their operator class, which is
# needed when performing correct LIKE queries outside the
# C locale. See #12234.
- db_type = f.db_type(connection=self.connection)
if db_type.startswith('varchar'):
output.append(get_index_sql('%s_%s_like' % (db_table, f.column),
' varchar_pattern_ops'))