Skip to content

Unittest error no such function: to_tsvector #67

Description

@chrisspen

I have a package that runs some unittests on a Django model with a VectorField. Since Django runs its unittests with an in-memory Sqlite3 database that doesn't support VectorField, it throws the error:

  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/django/db/models/base.py", line 546, in save
    force_update=force_update, update_fields=update_fields)
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/django/db/models/base.py", line 664, in save_base
    update_fields=update_fields, raw=raw, using=using)
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 170, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/djorm_pgfulltext/models.py", line 47, in auto_update_search_field_handler
    instance.update_search_field()
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/djorm_pgfulltext/models.py", line 111, in update_search_field
    self._fts_manager.update_search_field(pk=self.pk, using=using, config=config)
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/djorm_pgfulltext/models.py", line 169, in update_search_field
    cursor.execute(sql, params)
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 366, in execute
    six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e.args)), sys.exc_info()[2])
  File "/usr/local/myproject/.env/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 362, in execute
    return Database.Cursor.execute(self, query, params)
DatabaseError: no such function: to_tsvector

How would I work around this, just so my unittests will run? I'm not testing the full text search. I just need it to not break everything in Sqlite. Is there someway to make the field revert to a simple CharField just for Sqlite?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions