Opened 4 years ago

Last modified 4 years ago

#31549 closed Bug

Diffrent result from connection — at Initial Version

Reported by: Lawes Owned by: nobody
Component: Database layer (models, ORM) Version: 2.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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_atmonth=5, import_atyear=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.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top