Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ODBC SQL type -150 is not yet supported #307

Open
Augis363 opened this issue Oct 19, 2023 · 5 comments
Open

ODBC SQL type -150 is not yet supported #307

Augis363 opened this issue Oct 19, 2023 · 5 comments

Comments

@Augis363
Copy link

Augis363 commented Oct 19, 2023

There are some features which are not supported yet. Please check the Limitations first to see if your bug is listed.

Software versions

  • Django: 4.0.10
  • mssql-django: 1.3.0
  • python: 3.8.8
  • SQL Server: Azure SQL server
  • OS: Debian GNU/Linux 10 (buster) 10

Table schema and Model

Django default User model
Database Connection Settings
`
// Paste your database settings from Settings.py here.

`DATABASES = {
"default": {
"ENGINE": "mssql",
"NAME" ,
"HOST": ,
"PORT": "1433",
"USER": ,
"PASSWORD": ,
"OPTIONS": {
"driver": "ODBC Driver 17 for SQL Server",
},
}
}

USE_TZ = True
TIME_ZONE = "Europe/Amsterdam"

Problem description and steps to reproduce

Just running Django server and trying to log in to admin page throws "ODBC SQL type -150 is not yet supported"
Expected behavior and actual behavior

Login successful
Error message/stack trace

[2023-10-19 08:46:43 +0000] [8] [INFO] Starting gunicorn 20.1.0
[2023-10-19 08:46:43 +0000] [8] [INFO] Listening at: http://0.0.0.0:80 (8)
[2023-10-19 08:46:43 +0000] [8] [INFO] Using worker: sync
[2023-10-19 08:46:43 +0000] [14] [INFO] Booting worker with pid: 14
[2023-10-19 08:46:43 +0000] [15] [INFO] Booting worker with pid: 15
Internal Server Error: /admin/login/
Traceback (most recent call last):
File "/usr/app/.venv/lib/python3.8/site-packages/django/db/utils.py", line 98, in inner
return func(*args, **kwargs)
File "/usr/app/.venv/lib/python3.8/site-packages/mssql/base.py", line 664, in fetchmany
return self.format_rows(self.cursor.fetchmany(chunk))
pyodbc.ProgrammingError: ('ODBC SQL type -150 is not yet supported. column-index=2 type=-150', 'HY106')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/app/.venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 56, in inner
response = get_response(request)
File "/usr/app/.venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/app/.venv/lib/python3.8/site-packages/django/utils/decorators.py", line 46, in _wrapper
return bound_method(*args, **kwargs)
File "/usr/app/.venv/lib/python3.8/site-packages/django/views/decorators/cache.py", line 62, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/usr/app/.venv/lib/python3.8/site-packages/django/contrib/admin/sites.py", line 440, in login
return LoginView.as_view(**defaults)(request)
File "/usr/app/.venv/lib/python3.8/site-packages/django/views/generic/base.py", line 84, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/app/.venv/lib/python3.8/site-packages/django/utils/decorators.py", line 46, in _wrapper
return bound_method(*args, **kwargs)
File "/usr/app/.venv/lib/python3.8/site-packages/django/views/decorators/debug.py", line 92, in sensitive_post_parameters_wrapper
return view(request, *args, **kwargs)
File "/usr/app/.venv/lib/python3.8/site-packages/django/utils/decorators.py", line 46, in _wrapper
return bound_method(*args, **kwargs)
File "/usr/app/.venv/lib/python3.8/site-packages/django/utils/decorators.py", line 134, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/usr/app/.venv/lib/python3.8/site-packages/django/utils/decorators.py", line 46, in _wrapper
return bound_method(*args, **kwargs)
File "/usr/app/.venv/lib/python3.8/site-packages/django/views/decorators/cache.py", line 62, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/usr/app/.venv/lib/python3.8/site-packages/django/contrib/auth/views.py", line 67, in dispatch
return super().dispatch(request, *args, **kwargs)
File "/usr/app/.venv/lib/python3.8/site-packages/django/views/generic/base.py", line 119, in dispatch
return handler(request, *args, **kwargs)
File "/usr/app/.venv/lib/python3.8/site-packages/django/views/generic/edit.py", line 152, in post
if form.is_valid():
File "/usr/app/.venv/lib/python3.8/site-packages/django/forms/forms.py", line 205, in is_valid
return self.is_bound and not self.errors
File "/usr/app/.venv/lib/python3.8/site-packages/django/forms/forms.py", line 200, in errors
self.full_clean()
File "/usr/app/.venv/lib/python3.8/site-packages/django/forms/forms.py", line 434, in full_clean
self._clean_form()
File "/usr/app/.venv/lib/python3.8/site-packages/django/forms/forms.py", line 455, in _clean_form
cleaned_data = self.clean()
File "/usr/app/.venv/lib/python3.8/site-packages/django/contrib/auth/forms.py", line 217, in clean
self.user_cache = authenticate(
File "/usr/app/.venv/lib/python3.8/site-packages/django/views/decorators/debug.py", line 42, in sensitive_variables_wrapper
return func(*func_args, **func_kwargs)
File "/usr/app/.venv/lib/python3.8/site-packages/django/contrib/auth/init.py", line 77, in authenticate
user = backend.authenticate(request, credentials)
File "/usr/app/.venv/lib/python3.8/site-packages/django/contrib/auth/backends.py", line 42, in authenticate
user = UserModel._default_manager.get_by_natural_key(username)
File "/usr/app/.venv/lib/python3.8/site-packages/django/contrib/auth/base_user.py", line 46, in get_by_natural_key
return self.get(
{self.model.USERNAME_FIELD: username})
File "/usr/app/.venv/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/app/.venv/lib/python3.8/site-packages/django/db/models/query.py", line 492, in get
num = len(clone)
File "/usr/app/.venv/lib/python3.8/site-packages/django/db/models/query.py", line 302, in len
self._fetch_all()
File "/usr/app/.venv/lib/python3.8/site-packages/django/db/models/query.py", line 1507, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/usr/app/.venv/lib/python3.8/site-packages/django/db/models/query.py", line 57, in iter
results = compiler.execute_sql(
File "/usr/app/.venv/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1394, in execute_sql
return list(result)
File "/usr/app/.venv/lib/python3.8/site-packages/mssql/compiler.py", line 176, in _cursor_iter
for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
File "/usr/app/.venv/lib/python3.8/site-packages/mssql/compiler.py", line 176, in
for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
File "/usr/app/.venv/lib/python3.8/site-packages/django/db/utils.py", line 98, in inner
return func(*args, **kwargs)
File "/usr/app/.venv/lib/python3.8/site-packages/django/db/utils.py", line 91, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/usr/app/.venv/lib/python3.8/site-packages/django/db/utils.py", line 98, in inner
return func(*args, **kwargs)
File "/usr/app/.venv/lib/python3.8/site-packages/mssql/base.py", line 664, in fetchmany
return self.format_rows(self.cursor.fetchmany(chunk))
django.db.utils.ProgrammingError: ('ODBC SQL type -150 is not yet supported. column-index=2 type=-150', 'HY106')
Any other details that can be helpful

@mShan0
Copy link
Contributor

mShan0 commented Oct 19, 2023

Thanks for the report. Will be looking into this.

@mShan0
Copy link
Contributor

mShan0 commented Oct 24, 2023

Was it all admin users that cause this error?

@dauinsight
Copy link
Contributor

Hi @Augis363, SQL type -150 is SQL_VARIANT

We are currently working on support for SQL_VARIANT and will update you when it is released. Thank you

@andrew-kyle92
Copy link

Has there been a fix for this, yet?

@absci
Copy link
Contributor

absci commented Jun 7, 2024

There's already a PR in pyodbc repo that adds support for SQL variant. Looks like it'll be merged soon. So, we just need to wait for a new pyodbc release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants