Possible bug in queryset "gte" function

37 views
Skip to first unread message

jjddg...@gmail.com

unread,
Feb 1, 2017, 11:33:19 AM2/1/17
to Django users
Hi, guys.

If I'm not madly blind (which has been the case before, you know), there is a bug in the "__gte" function for the orm queryset. To name it, whenever I call the function, it gives the same result that the "__gt" function, that is, greater than or equal to, is behaving the same as greater than. 

In my specific case, I want to do a query over my database that return the rows registered between the 3th of december and the 4th, for which I have written:

Warehouse.objects.filter(date__gte="2016-12-03", date__lte="2016-12-04")

such queryset returns an empty set, even though I know there are registers within those two dates. Then I checked, and did only:

Warehouse.objects.filter(date__gte="2016-12-03")

and it returned rows with dates 2016-12-04 and higher, so... well, that the bug as far I can see.

Thanks for your replies and if someone can directly verify and report the bug, that would be awesome. 

Thanks.

Dylan Reinhold

unread,
Feb 1, 2017, 11:47:02 AM2/1/17
to django...@googlegroups.com
Your date field is probably a date-time field in your database.
So your filter is going to be looking for 2016-12-03 00:00:00 thru 2016-12-04 00:00:00.

Dylan


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2109d071-2065-4ebe-8608-6bdc30d0e64e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jjddg...@gmail.com

unread,
Feb 1, 2017, 12:05:28 PM2/1/17
to Django users
What you say does sound plausible since previously the field was a timestamp that I modified into a date, but then, what can I do?


On Wednesday, February 1, 2017 at 11:47:02 AM UTC-5, Dylan Reinhold wrote:
Your date field is probably a date-time field in your database.
So your filter is going to be looking for 2016-12-03 00:00:00 thru 2016-12-04 00:00:00.

Dylan

On Wed, Feb 1, 2017 at 6:16 AM, <jjddg...@gmail.com> wrote:
Hi, guys.

If I'm not madly blind (which has been the case before, you know), there is a bug in the "__gte" function for the orm queryset. To name it, whenever I call the function, it gives the same result that the "__gt" function, that is, greater than or equal to, is behaving the same as greater than. 

In my specific case, I want to do a query over my database that return the rows registered between the 3th of december and the 4th, for which I have written:

Warehouse.objects.filter(date__gte="2016-12-03", date__lte="2016-12-04")

such queryset returns an empty set, even though I know there are registers within those two dates. Then I checked, and did only:

Warehouse.objects.filter(date__gte="2016-12-03")

and it returned rows with dates 2016-12-04 and higher, so... well, that the bug as far I can see.

Thanks for your replies and if someone can directly verify and report the bug, that would be awesome. 

Thanks.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Dylan Reinhold

unread,
Feb 1, 2017, 8:14:43 PM2/1/17
to django...@googlegroups.com
After you changed it did you migrate the database? What database are you using?

Dylan

To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages