Steps to reproduce: 1. In Toaster, select a build, go the Configuration page and click on the "BitBake variables" tab 2. Search for something that will return results (for example, "kernel") 3. Click on the "Set in file" filter button and select the "Local configuration variables" option. Click "Apply" You get this error: Environment: Request Method: GET Request URL: http://localhost:8000/gui/build/65/configvars?filter=vhistory__file_name__regex%3Aconf%2F%28local%7Cbblayers%29.conf&count=100&search=kernel&page=1&orderby=variable_name%3A%2B Django Version: 1.5 Python Version: 2.7.3 Installed Applications: ('django.contrib.staticfiles', 'django.contrib.humanize', 'orm', 'toastermain', 'toastergui', 'bldviewer', 'south') Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware') Traceback: File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response 115. response = callback(request, *callback_args, **callback_kwargs) File "/home/yocto/poky/bitbake/lib/toaster/toastergui/views.py" in configvars 787. queryset = _get_queryset(Variable, queryset, filter_string, search_term, ordering_string) File "/home/yocto/poky/bitbake/lib/toaster/toastergui/views.py" in _get_queryset 187. if ordering_string and queryset: File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in __nonzero__ 141. return type(self).__bool__(self) File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in __bool__ 135. next(iter(self)) File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in _result_iter 123. self._fill_cache() File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in _fill_cache 939. self._result_cache.append(next(self._iter)) File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in _safe_iterator 344. for item in iterator: File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in iterator 301. for row in compiler.results_iter(): File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in results_iter 775. for rows in self.execute_sql(MULTI): File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in execute_sql 840. cursor.execute(sql, params) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py" in execute 41. return self.cursor.execute(sql, params) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py" in execute 366. six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e.args)), sys.exc_info()[2]) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py" in execute 362. return Database.Cursor.execute(self, query, params) Exception Type: DatabaseError at /gui/build/65/configvars Exception Value: user-defined function raised exception
It is the "regex" filter returning an empty set to a search that leads to the error. The filter in question is the "vhistory__file_name__regex:conf/(local|bblayers).conf" If I change the filter to ... filter=vhistory__file_name__contains:conf/bblayers.con ... it leads to an empty table and no errors. If I leave the filter but remove the "search=kernel" I get results returned and no error.
The bug is deeper than that, somewhere inside the handling of the lambda function from "_get_search_results" in the Django Q object filtering. The regex filtering in "_get_queryset" returns a successful queryset with some 20 entries. Then in "_get_search_results", the Q object filter call for the search terms does return, but the resulting queryset object is damaged, in that any method call ("exists", "count", ...) will immediately cause the reported error. I find that if I replace the Q object with a simple filter (no lamba), there is no error.
Is this a bug in the Q() in Django itself ?
(In reply to comment #3) > Is this a bug in the Q() in Django itself ? No, this is an issue with Sqlite3 engine. reference: http://www.gossamer-threads.com/lists/python/python/543700
commit 74e2f8501997143162855b970ffd9fdb33d24bd8
verified in master:db80f796e78746014a0f9497638e5c6fd2953ef0