Opened 14 years ago

Closed 12 years ago

#14757 closed Bug (wontfix)

Add An Example For .extra(tables=[])

Reported by: Mike Shultz Owned by: nobody
Component: Documentation Version: 1.2
Severity: Normal Keywords: documentation extra tables
Cc: shultzm@…, john@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: yes UI/UX: no

Description

When fiddling around trying to find a solution to one of my problems, it seems to be that .extra(tables=[]) was what I needed. I took a trip through the django documentation just to find that there were no examples, or even a description into what kind of 'string' it takes. Is it JOIN statements? Just a name of a table and/or matching columns?

Please add an example to the documentation and/or a better explanation of the string it accepts.

Reference: http://docs.djangoproject.com/en/dev/ref/models/querysets/#extra-select-none-where-none-params-none-tables-none-order-by-none-select-params-none

Attachments (2)

14757.diff (1009 bytes ) - added by John Paulett 14 years ago.
Add example using both tables and where in Queryset.extra()
querysets.txt.diff (979 bytes ) - added by Bernhard Essl 13 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 by Gabriel Hurley, 14 years ago

Triage Stage: UnreviewedAccepted

Agreed. There is an example for where, but not for tables. Adding this would be helpful.

by John Paulett, 14 years ago

Attachment: 14757.diff added

Add example using both tables and where in Queryset.extra()

comment:2 by John Paulett, 14 years ago

Cc: john@… added
Has patch: set

Attached a patch to add this documentation. The example is fairly trivial (in fact, it makes more sense as a simple filter())

comment:3 by anonymous, 14 years ago

Severity: Normal
Type: Bug

comment:4 by Chris Beaven, 14 years ago

Easy pickings: unset

The example follows the bad practice of embedding values in the where clause rather than in params

It'd also be better if the example was hypothetically useful.

comment:5 by Chris Beaven, 13 years ago

Easy pickings: set
Patch needs improvement: set

by Bernhard Essl, 13 years ago

Attachment: querysets.txt.diff added

comment:6 by Bernhard Essl, 13 years ago

UI/UX: unset

Added a patch with params using in the where clause.

comment:7 by Christopher Medrela, 13 years ago

Is this note necessary? I can't find any useful example of using extra(where=...) - everything can be done with objects.filter. I suggest to close this ticket.

comment:8 by James Aylett, 12 years ago

The documentation now explains what format tables should be in. I suspect that the only uses of this are fairly complex, and so the effort in explaining the context in documentation is going to outweigh the value of an actual example.

comment:9 by Tim Graham, 12 years ago

Resolution: wontfix
Status: newclosed

Agreed with the last two comments, if we can't come up with a useful example here I don't see much use in adding this.

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