Skip to content

Commit

Permalink
Fix to accept string based primary keys
Browse files Browse the repository at this point in the history
Primary Key can anything not only `Integer`.
For example [`UUID4`](https://docs.djangoproject.com/en/1.8/ref/models/fields/#uuidfield)
  • Loading branch information
Alir3z4 committed Nov 10, 2015
1 parent 6756b68 commit 545c4a2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions xapian_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,9 @@ def add_datetime_to_document(termpos, prefix, term, weight):
# `django_id` is an int and `django_ct` is text;
# besides, they are indexed by their (unstemmed) value.
if field['field_name'] == 'django_id':
value = int(value)
value = _term_to_xapian_value(value, field['type'])
value = str(value)
value = _term_to_xapian_value(value, 'text')


document.add_term(TERM_PREFIXES[field['field_name']] + value, weight)
document.add_value(field['column'], value)
Expand Down

0 comments on commit 545c4a2

Please sign in to comment.