Thanks for the help, I have checked those release notes, but I was not able to identify the related change (neither subquery nor __in lookup). I wanted to give you a deeper look into the code, but during that I managed to isolate the issue. It seems that the '__in' lookups previously accepted objects and automatically extracted the referenced columns in case of Foreign Key fields, but that is not valid now. I added `values('id')` everywhere, and it solved the problem. I am not sure how to feel about this change, as 'id' is automatically created.
Br,
Szabolcs
On Tue, Apr 23, 2019 at 4:39 PM Simon Charette <charette.s@gmail.com> wrote:
--I assume you are either using a Subquery annotation that returnsmultiple results or an __in lookup against a query with multiple columns.I vaguely remember something changed in this area but it was documentedin one of the 2.0, 2.1 or 2.2 release notes.Best,Simon
Le mardi 23 avril 2019 10:31:43 UTC-4, hodossy...@gmail.com a écrit :Hello,I am facing the following issue after upgrading to 2.2 from 1.11. Here is the stack trace:Traceback (most recent call last):File "(...)\.env\lib\site-packages\django\db\backends\utils.py", line 84, in _executereturn self.cursor.execute(sql, params)File "(...)\.env\lib\site-packages\django\db\backends\sqlite3\base.py", line 383, in executereturn Database.Cursor.execute(self, query, params)sqlite3.OperationalError: only a single result allowed for a SELECT that is part of an expressionThe above exception was the direct cause of the following exception:Traceback (most recent call last):File "(...)\dashboard\deployment\tests\test_view.py", line 53, in test_display_list_viewresponse = self.client.get(self.url_my_list)File "(...)\.env\lib\site-packages\django\test\client.py", line 535, in getresponse = super().get(path, data=data, secure=secure, **extra)File "(...)\.env\lib\site-packages\django\test\client.py", line 347, in get**extra,File "(...)\.env\lib\site-packages\django\test\client.py", line 422, in genericreturn self.request(**r)File "(...)\.env\lib\site-packages\django\test\client.py", line 503, in requestraise exc_valueFile "(...)\.env\lib\site-packages\django\core\handlers\exception.py", line 34, in innerresponse = get_response(request)File "(...)\.env\lib\site-packages\django\core\handlers\base.py", line 115, in _get_responseresponse = self.process_exception_by_middleware(e, request)File "(...)\.env\lib\site-packages\django\core\handlers\base.py", line 113, in _get_responseresponse = wrapped_callback(request, *callback_args, **callback_kwargs)File "(...)\.env\lib\site-packages\django\views\generic\base.py", line 71, in viewreturn self.dispatch(request, *args, **kwargs)File "(...)\.env\lib\site-packages\django\contrib\auth\mixins.py", line 52, in dispatchreturn super().dispatch(request, *args, **kwargs)File "(...)\.env\lib\site-packages\django\views\generic\base.py", line 97, in dispatchreturn handler(request, *args, **kwargs)File "(...)\.env\lib\site-packages\django\views\generic\list.py", line 157, in getcontext = self.get_context_data()File "(...)\dashboard\deployment\views.py", line 53, in get_context_datacontext = super().get_context_data(**kwargs)File "(...)\.env\lib\site-packages\django\views\generic\list.py", line 119, in get_context_datapaginator, page, queryset, is_paginated = self.paginate_queryset(queryset, page_size)File "(...)\.env\lib\site-packages\django\views\generic\list.py", line 69, in paginate_querysetpage = paginator.page(page_number)File "(...)\.env\lib\site-packages\django\core\paginator.py", line 70, in pagenumber = self.validate_number(number)File "(...)\.env\lib\site-packages\django\core\paginator.py", line 48, in validate_numberif number > self.num_pages:File "(...)\.env\lib\site-packages\django\utils\functional.py", line 80, in __get__res = instance.__dict__[self.name] = self.func(instance)File "(...)\.env\lib\site-packages\django\core\paginator.py", line 97, in num_pagesif self.count == 0 and not self.allow_empty_first_page:File "(...)\.env\lib\site-packages\django\utils\functional.py", line 80, in __get__res = instance.__dict__[self.name] = self.func(instance)File "(...)\.env\lib\site-packages\django\core\paginator.py", line 91, in countreturn c()File "(...)\.env\lib\site-packages\django\db\models\query.py", line 392, in countreturn self.query.get_count(using=self.db)File "(...)\.env\lib\site-packages\django\db\models\sql\query.py", line 504, in get_countnumber = obj.get_aggregation(using, ['__count'])['__count']File "(...)\.env\lib\site-packages\django\db\models\sql\query.py", line 489, in get_aggregationresult = compiler.execute_sql(SINGLE)File "(...)\.env\lib\site-packages\django\db\models\sql\compiler.py", line 1097, in execute_sqlcursor.execute(sql, params)File "(...)\.env\lib\site-packages\django\db\backends\utils.py", line 67, in executereturn self._execute_with_wrappers(sql, params, many=False, executor=self._execute)File "(...)\.env\lib\site-packages\django\db\backends\utils.py", line 76, in _execute_with_wrappersreturn executor(sql, params, many, context)File "(...)\.env\lib\site-packages\django\db\backends\utils.py", line 84, in _executereturn self.cursor.execute(sql, params)File "(...)\.env\lib\site-packages\django\db\utils.py", line 89, in __exit__raise dj_exc_value.with_traceback(traceback) from exc_valueFile "(...)\.env\lib\site-packages\django\db\backends\utils.py", line 84, in _executereturn self.cursor.execute(sql, params)File "(...)\.env\lib\site-packages\django\db\backends\sqlite3\base.py", line 383, in executereturn Database.Cursor.execute(self, query, params)django.db.utils.OperationalError: only a single result allowed for a SELECT that is part of an expressionIt seems that during pagination some query is made that is not supported by SQLite. Did anybody face the same issue? I am using Python 3.6 with SQLite 3.14.Thanks in advance,Szabolcs
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8b7a762f-4aab-4a18-b160-ee53995e0ef1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFp9oi_swqgT3_RArWyRJ_Mfp0z3szOZ7QRznydc2WXOvjHbaw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment