1
0
mirror of https://github.com/django/django.git synced 2025-10-29 00:26:07 +00:00

[1.6.x] Fixed #22514 -- Prevented indexes on virtual fields [postgres].

Backport of 78c32f1caa from master
This commit is contained in:
Vlastimil Zíma
2014-05-19 18:19:35 +02:00
committed by Tim Graham
parent d4a3fd44f0
commit ef3ae3d1c9
4 changed files with 38 additions and 3 deletions

View File

@@ -41,7 +41,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
@@ -67,7 +68,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'))