Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#5115 closed (fixed)

ORM does not support query set subscription with long numbers

Reported by: zboczuch <zboczuch@…> Owned by: adrian
Component: Core (Other) Version: master
Severity: Keywords: orm query set slice indexing
Cc: zboczuch@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

> from app.models import foo

> foo.objects.all()[2L]

<type 'exceptions.TypeError'> 

Longs are allowed in slices. I think the problem is in django/db/models/query.py:

{{
def getitem(self, k):

"Retrieve an item or slice from the set of results."
if not isinstance(k, (slice, int)):

}}

"long" should be added to the type list above.

Change History (5)

comment:1 Changed 8 years ago by zboczuch <zboczuch@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Hm... My mistake in formating:

def getitem(self, k):
    "Retrieve an item or slice from the set of results."
    if not isinstance(k, (slice, int)):

comment:2 Changed 8 years ago by zboczuch <zboczuch@…>

  • Cc zboczuch@… added

comment:3 follow-up: Changed 8 years ago by zboczuch <zboczuch@…>

Ooops! This ticket system shows my email to everyone. Is there a possibility to hide it?

comment:4 Changed 8 years ago by gwilson

  • Resolution set to fixed
  • Status changed from new to closed

(In [5831]) Fixed #5115 -- Fixed QuerySet slices to allow longs.

comment:5 in reply to: ↑ 3 Changed 8 years ago by gwilson

Replying to zboczuch <zboczuch@paranoja.pl>:

Ooops! This ticket system shows my email to everyone. Is there a possibility to hide it?

I could remove your email from the ticket description and cc, but I don't think I could do anything about the comments.

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