django-include icon indicating copy to clipboard operation
django-include copied to clipboard

Test against sqlite3

Open sloria opened this issue 7 years ago • 0 comments

We are evaluating using in-memory sqlite3 to speed up our OSF tests. Let's get sqlite3 working in django-include.

I changed the test settings to:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': ':memory:'
    }
}

Miraculously, only 1 test fails:

tox -e py36-django111
_____________________________ TestGenericForeignKey.test_reverse_gfk __________________________________________________________________________________
.tox/py36-django111/lib/python3.6/site-packages/django/db/backends/utils.py:64: in execute
    return self.cursor.execute(sql, params)
.tox/py36-django111/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py:328: in execute
    return Database.Cursor.execute(self, query, params)
E   sqlite3.OperationalError: near "ORDER": syntax error

The above exception was the direct cause of the following exception:
tests/test_include.py:325: in test_reverse_gfk
    ket = models.Cat.objects.include('aliases').get(pk=cat.id)
.tox/py36-django111/lib/python3.6/site-packages/django/db/models/query.py:374: in get
    num = len(clone)
.tox/py36-django111/lib/python3.6/site-packages/django/db/models/query.py:232: in __len__
    self._fetch_all()
.tox/py36-django111/lib/python3.6/site-packages/django/db/models/query.py:1118: in _fetch_all
    self._result_cache = list(self._iterable_class(self))
include/query.py:76: in __iter__
    for instance in super(IncludeModelIterable, self).__iter__():
.tox/py36-django111/lib/python3.6/site-packages/django/db/models/query.py:53: in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
.tox/py36-django111/lib/python3.6/site-packages/django/db/models/sql/compiler.py:899: in execute_sql
    raise original_exception
.tox/py36-django111/lib/python3.6/site-packages/django/db/models/sql/compiler.py:889: in execute_sql
    cursor.execute(sql, params)
.tox/py36-django111/lib/python3.6/site-packages/django/db/backends/utils.py:79: in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
.tox/py36-django111/lib/python3.6/site-packages/django/db/backends/utils.py:64: in execute
    return self.cursor.execute(sql, params)
.tox/py36-django111/lib/python3.6/site-packages/django/db/utils.py:94: in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
.tox/py36-django111/lib/python3.6/site-packages/django/utils/six.py:685: in reraise
    raise value.with_traceback(tb)
.tox/py36-django111/lib/python3.6/site-packages/django/db/backends/utils.py:64: in execute
    return self.cursor.execute(sql, params)
.tox/py36-django111/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py:328: in execute
    return Database.Cursor.execute(self, query, params)
E   django.db.utils.OperationalError: near "ORDER": syntax error

I don't have time to look into it further right now, so just opening this issue as a TODO.

sloria avatar Sep 21 '18 21:09 sloria