-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Error Traceback
`Environment:
Request Method: GET
Django Version: 1.8.18
Python Version: 3.4.2
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'django_filters')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware')
Traceback:
162. self._fetch_all()
File "/.virtualenvs/name.project/lib/python3.4/site-packages/django/db/models/query.py" in _fetch_all
965. self._result_cache = list(self.iterator())
File "/.virtualenvs/name.project/lib/python3.4/site-packages/django/db/models/query.py" in iterator
1085. for row in self.query.get_compiler(self.db).results_iter():
File "/.virtualenvs/name.project/lib/python3.4/site-packages/django/db/models/sql/compiler.py" in results_iter
794. results = self.execute_sql(MULTI)
File "/.virtualenvs/name.project/lib/python3.4/site-packages/django/db/models/sql/compiler.py" in execute_sql
829. sql, params = self.as_sql()
File "/.virtualenvs/name.project/lib/python3.4/site-packages/sqlany_django/compiler.py" in as_sql
14. subquery=subquery)
File "/.virtualenvs/name.project/lib/python3.4/site-packages/django/db/models/sql/compiler.py" in as_sql
434. for _, (o_sql, o_params, _) in order_by:
Exception Type: ValueError at /name/api
Exception Value: too many values to unpack (expected 2)`
Pseudo code which caused error:
list(Model.objects.filter(key=value).values('key').annotate(new_name=Sum('key')))I found out that error is caused by:
sqlany_django/base.py
line 269
def force_no_ordering(self):
"""
"ORDER BY NULL" prevents SQL Anywhere from implicitly ordering by grouped
columns. If no ordering would otherwise be applied, we don't want any
implicit sorting going on.
"""
return ["NULL"]which return wrong number of values.
The function should return an empty list or a structure which can be iterated in this for loop:
django/db/models/sql/compiler.py line 434
for _, (o_sql, o_params, _) in order_by:In mysql force_no_ordering method is returning:
[(None, ("NULL", [], False))]I am not expert of SQLAnywhere but if there is any real difference between:
SELECT * FROM name;
and
SELECT * FROM name ORDER BY NULL
If not than returning empty list would be enough because than the for loop on which error is raised would not be ran.
I am not sure as well how the code looked in previous versions of django, maybe the issue is caused by lack of compatibility for django 1.8 in the code area where I found a bug ?