Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Index creation fails on field.db_type() is None #1367

Closed
wants to merge 1 commit into from

3 participants

@jarus

Sometimes field.db_type doesn't return a value what should raise an index creation error. As example the GeoDjango Point field doesn't return a value in this state.

@jarus jarus Index creation fails on field.db_type() is None
Sometimes field.db_type doesn't return a value what should raise an index creation error.
535e519
@timgraham
Owner

Could you add a test that demonstrates the problem?

@jarus

Do you mean a test in the Django Test Suite or another test?

@timgraham
Owner

Yes, the Django test suite. It's helpful to have regression tests for all bug fixes.

@jarus

Okay. Do you know a place where I can put the regression test? It must be somewhere I can catch the Test DB creation.

@claudep
Collaborator

See my comment on the ticket.

@claudep claudep closed this
@jarus jarus deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 18, 2013
  1. @jarus

    Index creation fails on field.db_type() is None

    jarus authored
    Sometimes field.db_type doesn't return a value what should raise an index creation error.
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 django/db/backends/postgresql_psycopg2/creation.py
View
4 django/db/backends/postgresql_psycopg2/creation.py
@@ -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
Something went wrong with that request. Please try again.