question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid query is generated: For field=BitField

See original GitHub issue

Hi all, thanks for your work on this. Noticed the below when testing version 2.8.1 with not yet supported Django 3.1.1. However, it works as expected up to version 3.0.10. Just adding this here fwiw or any that misinterpret “Django 2.2 or newer” 😃.

models.py:

class Book(models.Model):
    BitField = models.BooleanField(db_column="BitField", default=0)

query: queryset = Book.objects.filter(BitField=True)

Generated T-SQL (Django 3.1.1):

SELECT TOP 10 dbo.Book.PK, dbo.Book.BitField
FROM dbo.Book
WHERE NOT dbo.Book.BitField

-- For Django up to 3.0.10 the correct T-SQL is generated:
-- ... WHERE dbo.Book.BitField = 0

Error: An expression of non-boolean type specified in a context where a condition is expected, near ‘BitField’.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:6
  • Comments:7

github_iconTop GitHub Comments

5reactions
MadPepecommented, Sep 10, 2020

Had the same issue. We had to downgrade to 3.0.10 version of Django and the problem disappeared.

Dependencies (Not working):

  • Django==3.1
  • django-mssql-backend==2.8.1
  • pyodbc==4.0.30
2reactions
sekar-pcommented, Feb 11, 2021

Issue exists in django3.1.6 also. When we can expect the fixed version in PyPI

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · ESSolutions/django-mssql-backend - GitHub
AttributeError: 'Query' object has no attribute 'explain_query'. #125 opened on May 4 by DiegoMagg ... Invalid query is generated: For field=BitField.
Read more >
I get an "Error! Invalid Query!" message when there is a ...
Diagnose this problem by going in the Salesforce section on Jira > Connections > Configure > Click on the "Fields" of the object...
Read more >
BPF CO-RE reference guide - Andrii Nakryiko's Blog
A practical reference guide to using the full power of BPF CO-RE (Compile Once – Run Everywhere).
Read more >
Apache Spark 3.0 Adaptive Query Execution - Morioh
It optimizes the query logically then generates a range of physical plans and ... An InvalidOptionException will be thrown in case an invalid...
Read more >
Logonid Record Fields - TechDocs - Broadcom Inc.
Specifies the number of system accesses made since this logonid was ... Through the IMS AUTH operand, a site can choose to use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found