Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#19151 closed Bug (fixed)

EmptyQuerySet is missing overrides for values() and values_list() methods.

Reported by: Bradley Ayers <brad@…> Owned by: Jan Bednařík
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

AnonymousUser.groups breaks down it's facade with values(), values_list():

>>> AnonymousUser().groups.values_list('name')
Traceback (most recent call last):
  File "<snip>", line 1, in <module>
  File "<snip>/django/db/models/manager.py", line 182, in values_list
    return self.get_query_set().values_list(*args, **kwargs)
  File "<snip>/django/db/models/query.py", line 585, in values_list
    _fields=fields)
  File "<snip>/django/db/models/query.py", line 1138, in _clone
    c = super(EmptyQuerySet, self)._clone(klass, setup=setup, **kwargs)
  File "<snip>/django/db/models/query.py", line 864, in _clone
    c._setup_query()
  File "<snip>/django/db/models/query.py", line 988, in _setup_query
    self.query.add_fields(self.field_names, True)
  File "<snip>/django/db/models/sql/query.py", line 1643, in add_fields
    alias = self.get_initial_alias()
  File "<snip>/django/db/models/sql/query.py", line 840, in get_initial_alias
    alias = self.join((None, self.model._meta.db_table, None, None))
AttributeError: 'NoneType' object has no attribute '_meta'
>>> AnonymousUser().groups.values_list()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "<snip>/django/db/models/manager.py", line 182, in values_list
    return self.get_query_set().values_list(*args, **kwargs)
  File "<snip>/django/db/models/query.py", line 585, in values_list
    _fields=fields)
  File "<snip>/django/db/models/query.py", line 1138, in _clone
    c = super(EmptyQuerySet, self)._clone(klass, setup=setup, **kwargs)
  File "<snip>/django/db/models/query.py", line 864, in _clone
    c._setup_query()
  File "<snip>/django/db/models/query.py", line 982, in _setup_query
    self.field_names = [f.attname for f in self.model._meta.fields]
AttributeError: 'NoneType' object has no attribute '_meta'

Change History (5)

comment:1 by Jan Bednařík, 12 years ago

Component: contrib.authDatabase layer (models, ORM)
Owner: changed from nobody to Jan Bednařík
Status: newassigned
Summary: AnonymousUser().groups.value_list('name') raises AttributeErrorEmptyQuerySet is missing overrides for values() and values_list() methods.

comment:2 by Jan Bednařík, 12 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Jan Bednařík, 12 years ago

Has patch: set
Triage Stage: AcceptedReady for checkin
Version: 1.4master

comment:4 by Jan Bednařík <jan.bednarik@…>, 12 years ago

Resolution: fixed
Status: assignedclosed

In b87e2f46c80d15abcda0e181ab894fb938ceb12f:

Fixed #19151 -- Added missing methods to EmptyQuerySet.

Added values() and values_list() methods to EmptyQuerySet.

comment:5 by Alex Gaynor <alex.gaynor@…>, 12 years ago

In 6b0d93df18a5c265f87ee6e64dbdffbdecfcea4f:

Merge pull request #456 from JanBednarik/ticket_19151

Fixed #19151 -- Added missing methods to EmptyQuerySet.

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