Skip to content

Commit

Permalink
Index creation fails on field.db_type() is None
Browse files Browse the repository at this point in the history
Sometimes field.db_type doesn't return a value what should raise an index creation error.
  • Loading branch information
jarus committed Jul 18, 2013
1 parent a3e7d73 commit 535e519
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions django/db/backends/postgresql_psycopg2/creation.py
Expand Up @@ -68,10 +68,10 @@ def get_index_sql(index_name, opclass=''):
# 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'):
if db_type and db_type.startswith('varchar'):
output.append(get_index_sql('%s_%s_like' % (db_table, f.column),
' varchar_pattern_ops'))
elif db_type.startswith('text'):
elif db_type and db_type.startswith('text'):
output.append(get_index_sql('%s_%s_like' % (db_table, f.column),
' text_pattern_ops'))
return output

0 comments on commit 535e519

Please sign in to comment.