#31549: Diffrent result from connection
-------------------------------------+-------------------------------------
Reporter: MrLawes | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 2.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by MrLawes:
Old 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_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.
New 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_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.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/31549#comment:1>
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/065.1935c00916261564a488ec7382467e93%40djangoproject.com.