#31549: Diffrent result from connection
-------------------------------------+-------------------------------------
               Reporter:  MrLawes    |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  2.0
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 We have a class:

 from django.db.models import models
 class MyModel(models.Model):
     import_at = models.DateField( db_index=True, null=True, default=None,)

 then I can get some results by:

 queryset = MyModel.objects.filter(import_at__month=5,
 import_at__year=import_at[0])
 print(queryset.count())
 >>>  4

 but when I used connection, I got diffrent result:

 from django.db import transaction, connection
 with connection.cursor() as cursor:
     cursor.execute(queryset.query)
     print(len(cursor.fetchall()))

 >>> 0

 I got 0 !

 If I using __month or __year, and get result by
 cursor.execute(queryset.query), we have diffrent result from connection.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31549>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.fe94f949a6aa2ef7c3c4f1ba62fbd3a3%40djangoproject.com.

Reply via email to