﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
31549	Diffrent result from connection	Lawes	nobody	"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())
It will print  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()))

It will print 0

I got 0 !

If I using __month or __year, and get result by cursor.execute(queryset.query), we have diffrent result from connection.


"	Bug	new	Database layer (models, ORM)	2.0	Normal				Unreviewed	0	0	0	0	0	0
