You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looks like pyodbc backend reports compatibility with postgre specific SQL functions.
For example, using contains lookup results in SQL error due to JSON_CONTAINS being used instead of raising unsupported exception.
Other example, result of using queryset.filter(jsonfield__has_key="some_key") is as below:
Environment:
Request Method: POST
Request URL: http://localhost:8000/admin/pconfig/model_with_jsonfield/
Django Version: 3.1.4
Python Version: 3.9.1
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django_cleanup.apps.CleanupConfig',
'django_q',
'social_django',
'crispy_forms',
'widget_tweaks',
'colorfield',
'django_admin_listfilter_dropdown',
'flat_json_widget',
'django_summernote',
'helpers',
'hub',
'dashboard',
'changelog',
'pconfig',
'pload']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback (most recent call last):
File "C:\dev_stor\ps-dev_env\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
response = get_response(request)
File "C:\dev_stor\ps-dev_env\lib\site-packages\django\core\handlers\base.py", line 179, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\dev_stor\ps-dev_env\lib\site-packages\django\contrib\admin\options.py", line 614, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "C:\dev_stor\ps-dev_env\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "C:\dev_stor\ps-dev_env\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "C:\dev_stor\ps-dev_env\lib\site-packages\django\contrib\admin\sites.py", line 233, in inner
return view(request, *args, **kwargs)
File "C:\dev_stor\emea-ps_dev\ap-pat\pconfig\admin.py", line 175, in changelist_view
return super().changelist_view(request, extra_context=extra_context)
File "C:\dev_stor\ps-dev_env\lib\site-packages\django\utils\decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "C:\dev_stor\ps-dev_env\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "C:\dev_stor\ps-dev_env\lib\site-packages\django\contrib\admin\options.py", line 1719, in changelist_view
response = self.response_action(request, queryset=cl.get_queryset(request))
File "C:\dev_stor\ps-dev_env\lib\site-packages\django\contrib\admin\options.py", line 1402, in response_action
response = func(self, request, queryset)
File "C:\dev_stor\emea-ps_dev\ap-pat\pconfig\admin.py", line 191, in delete_option
for obj in queryset:
File "C:\dev_stor\ps-dev_env\lib\site-packages\django\db\models\query.py", line 287, in __iter__
self._fetch_all()
File "C:\dev_stor\ps-dev_env\lib\site-packages\django\db\models\query.py", line 1308, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "C:\dev_stor\ps-dev_env\lib\site-packages\django\db\models\query.py", line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "C:\dev_stor\ps-dev_env\lib\site-packages\django\db\models\sql\compiler.py", line 1143, in execute_sql
sql, params = self.as_sql()
File "C:\dev_stor\ps-dev_env\lib\site-packages\sql_server\pyodbc\compiler.py", line 189, in as_sql
where, w_params = self.compile(self.where) if self.where is not None else ("", [])
File "C:\dev_stor\ps-dev_env\lib\site-packages\sql_server\pyodbc\compiler.py", line 358, in compile
return super().compile(node, *args, **kwargs)
File "C:\dev_stor\ps-dev_env\lib\site-packages\django\db\models\sql\compiler.py", line 430, in compile
sql, params = node.as_sql(self, self.connection)
File "C:\dev_stor\ps-dev_env\lib\site-packages\django\db\models\sql\where.py", line 81, in as_sql
sql, params = compiler.compile(child)
File "C:\dev_stor\ps-dev_env\lib\site-packages\sql_server\pyodbc\compiler.py", line 358, in compile
return super().compile(node, *args, **kwargs)
File "C:\dev_stor\ps-dev_env\lib\site-packages\django\db\models\sql\compiler.py", line 428, in compile
sql, params = vendor_impl(self, self.connection)
File "C:\dev_stor\ps-dev_env\lib\site-packages\sql_server\pyodbc\functions.py", line 81, in sqlserver_lookup
return lookup.as_sql(compiler, connection)
File "C:\dev_stor\ps-dev_env\lib\site-packages\django\db\models\fields\json.py", line 178, in as_sql
sql = template % lhs
Exception Type: TypeError at /admin/pconfig/model_with_jsonfield/
Exception Value: unsupported operand type(s) for %: 'NoneType' and 'str'
The text was updated successfully, but these errors were encountered:
Looks like pyodbc backend reports compatibility with postgre specific SQL functions.
For example, using
contains
lookup results in SQL error due toJSON_CONTAINS
being used instead of raising unsupported exception.Other example, result of using
queryset.filter(jsonfield__has_key="some_key")
is as below:The text was updated successfully, but these errors were encountered: