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

Support for Django 3.1.x? #90

Open
hannylicious opened this issue Nov 18, 2020 · 17 comments
Open

Support for Django 3.1.x? #90

hannylicious opened this issue Nov 18, 2020 · 17 comments

Comments

@hannylicious
Copy link

Just writing to see if there are plans for supporting Django 3.1.x

We were considering moving - but when we attempted to do so we ran into a lot of MSSQL errors (varying in degree and varying across applications).

Downgrading to 3.0.x fixes all issues. Just curious if there is a timeline for 3.1.x versions? I checked online but couldn't find any mention of it anywhere.

@lukesavvatiller
Copy link

Really want to move to 3.1.x

@OskarPersson
Copy link
Collaborator

@hannylicious Please report any (not already reported) issues found when using the latest commit in master here (which should support the basics of 3.1)

@lukesavvatiller
Copy link

lukesavvatiller commented Jan 12, 2021

The error i am getting is
django.db.utils.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]An expression of non-boolean type specified in a context where a condition is expected, near 'AND'. (4145) (SQLExecDirectW); [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Statement(s) could not be prepared. (8180)")

When trying to query on boolean fields such as Portfolios.objects_for_user.get_queryset(request=request, is_active=True, portfolio_reference=portfolio_reference).

The is_active field is a boolean and the sql being generated is not valid. It generates SQL saying WHERE boolean instead of WHERE boolean=1

@OskarPersson
Copy link
Collaborator

I will need a more complete example to debug this

@aceofwings
Copy link

aceofwings commented Jan 12, 2021

Somethings that are not supported at the moment, example with the addition of collations, most recent release versions will not be able to dbinspect as introspection will be needed. I will submit a formal issue.

here

@rmControls
Copy link

rmControls commented Feb 2, 2021

I am also getting similar error after update to django 3.1

seems like it is incompatible with django_q and some other packages

steps to produce error:
install django 3.0.x django-mssql-backend, django_q
=> create some que with django_q
=> update django 3.0.1 to 3.1
goto admin and try to acess django_q section

Request Method: | GET
-- | --
http://127.0.0.1:8000/adminactivities/django_q/failure/
3.1.5
ProgrammingError
('42000', "[42000] [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]An expression of non-boolean type specified in a context where a condition is expected, near 'success'. (4145) (SQLExecDirectW)")
C:\Users\xxxxx\.conda\envs\envdj3\lib\site-packages\sql_server\pyodbc\base.py, line 553, in execute
C:\Users\xxxxx\.conda\envs\envdj3\python.exe
3.8.5

I am in bad need of updating to 3.1... request you to provide ETA for 3.1...
Also 3.2 release is nearing....

@OskarPersson
Copy link
Collaborator

@rmControls Does the master branch work for you?

To learn how to install from a git repo please see: https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support

@rmControls
Copy link

rmControls commented Feb 2, 2021

Looks good... checked with django q module and seems like it it working....

I will check the other packages and report errors if I find it....

thanks for the quick solution....

@hannylicious
Copy link
Author

I'm still struggling with a similar error as others in this thread regarding moving to 3.1 - this same error occurs across a few applications here and there for us.

This was what we saw doing a regular pip install of the latest release:

django.db.utils.ProgrammingError: (‘42000’, “[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]An expression of non-boolean type specified in a context where a condition is expected, near ‘AND’. (4145) (SQLExecDirectW); [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Incorrect syntax near ‘)’.

Same application works fine with Django 3.0.x, so we're staying there for now - but we're approaching end of life with Django 3.0.x so we'd like to migrate...

Any thoughts on when full 3.1.x support might be ready?

Additional Information ('master branch fix'):

I've installed from the 'master branch', and while that appears (at least locally) to have eliminated some of the immediate SQL issues which prevented it from working in some apps - others are still running into SQL issues.

I'm not sure installing from from master branch is a real good solution for those of us relying on using requirements.txt to be the source of our packages - unless there is a way to do that in the requirements file without having to manually install from master branch? Any thoughts on when 'master branch' might become the pip installable version?

@namndt
Copy link

namndt commented Mar 6, 2021

The error i am getting is
django.db.utils.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]An expression of non-boolean type specified in a context where a condition is expected, near 'AND'. (4145) (SQLExecDirectW); [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Statement(s) could not be prepared. (8180)")

When trying to query on boolean fields such as Portfolios.objects_for_user.get_queryset(request=request, is_active=True, portfolio_reference=portfolio_reference).

The is_active field is a boolean and the sql being generated is not valid. It generates SQL saying WHERE boolean instead of WHERE boolean=1

Please, I have same issue. How to fix it?

@lukesavvatiller
Copy link

Any update on this bug? Anything we need to provide that can help getting it fixed/ included in pip install?

@hannylicious
Copy link
Author

@lukesavvatiller I fear this repo has gone or is going in the same direction as the original one that this was forked off of.

@jwaschkau
Copy link

The MS open source project which is a fork from this one will release the patch this month.

microsoft/mssql-django#13

@hannylicious
Copy link
Author

@jwaschkau excellent! I know myself and others have been waiting anxiously for a Microsoft supported version of this driver to be out!

I'm glad @OskarPersson picked up the old project and created this one to get us to this point! I appreciate that work, for sure.

@mcante
Copy link

mcante commented Jun 20, 2022

En mi caso pasé mucho tiempo intentando, estoy con Django 3.2. Me funcionó hacerlo con el paquete mssql.

@gabriribeiro5
Copy link

Hi! Any updates on this? I'm having the same problem as below. I've updated django up to 3.2.1 where boolean issues are quoted on bug fixes but the problem persist.

Tks for helping

The error i am getting is django.db.utils.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]An expression of non-boolean type specified in a context where a condition is expected, near 'AND'. (4145) (SQLExecDirectW); [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Statement(s) could not be prepared. (8180)")

When trying to query on boolean fields such as Portfolios.objects_for_user.get_queryset(request=request, is_active=True, portfolio_reference=portfolio_reference).

The is_active field is a boolean and the sql being generated is not valid. It generates SQL saying WHERE boolean instead of WHERE boolean=1

@lucasjl
Copy link

lucasjl commented Mar 13, 2024

Hi! Any updates on this? I'm having the same problem as below. I've updated django up to 3.2.1 where boolean issues are quoted on bug fixes but the problem persist.

Tks for helping

The error i am getting is django.db.utils.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]An expression of non-boolean type specified in a context where a condition is expected, near 'AND'. (4145) (SQLExecDirectW); [42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Statement(s) could not be prepared. (8180)")
When trying to query on boolean fields such as Portfolios.objects_for_user.get_queryset(request=request, is_active=True, portfolio_reference=portfolio_reference).
The is_active field is a boolean and the sql being generated is not valid. It generates SQL saying WHERE boolean instead of WHERE boolean=1

Pypi mentions django-mssql-backend supporting up to Django 3.0. For later versions you could try to use a fork of this package named mssql-django (https://github.com/microsoft/mssql-django)

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

10 participants