Opened 7 years ago

Closed 7 years ago

#7045 closed (fixed)

extra(tables=...) was sometimes causing an exception

Reported by: anonymous Owned by: nobody
Component: Database layer (models, ORM) Version: queryset-refactor
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by mtredinnick)

Customer.objects.extra(select={'mid' : '!'}, tables=['customerj'], where=['!'])

raises exception:

Request Method:  	POST[[BR]]
Request URL: 	! [[BR]]
Exception Type: 	!KeyError[[BR]]
Exception Value: 	'customerj'[[BR]]
Exception Location: 	/home/bring/src/queryset-refactor/django/db/models/sql/ in get_from_clause, line 423[[BR]]
Python Executable: 	/usr/bin/python[[BR]]
Python Version: 	2.5.1

Change History (3)

comment:1 Changed 7 years ago by mtredinnick

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Fixed description.

comment:2 Changed 7 years ago by mtredinnick

  • Summary changed from db.models.sql.Query.add_extra() does not append extra tables to Query.alias_map dict to extra(tables=...) was sometimes causing an exception
  • Triage Stage changed from Unreviewed to Accepted

The original title of this ticket isn't actually a bug; it's intentional. I've changed the title to reflect the real problem a bit better in case somebody else is seeing this.

After a bit of experimenting, however, I was able to repeat the problem you're seeing and it's not quite for the reason you thought. It only happened when get_from_clause() was called more than once. The commit to fix this ticket handles that case now.

comment:3 Changed 7 years ago by mtredinnick

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

(In [7447]) queryset-refactor: Fixed a crash when using extra(tables=...). Fixed #7045.

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