Opened 6 years ago

Closed 4 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 6 years ago.
Add example using both tables and where in Queryset.extra()
querysets.txt.diff (979 bytes) - added by Bernhard Essl 5 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 6 years ago by Gabriel Hurley

Triage Stage: UnreviewedAccepted

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

Changed 6 years ago by John Paulett

Attachment: 14757.diff added

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

comment:2 Changed 6 years ago by John Paulett

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 Changed 6 years ago by anonymous

Severity: Normal
Type: Bug

comment:4 Changed 6 years ago by Chris Beaven

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 Changed 6 years ago by Chris Beaven

Easy pickings: set
Patch needs improvement: set

Changed 5 years ago by Bernhard Essl

Attachment: querysets.txt.diff added

comment:6 Changed 5 years ago by Bernhard Essl

UI/UX: unset

Added a patch with params using in the where clause.

comment:7 Changed 5 years ago by Christopher Medrela

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 Changed 4 years ago by James Aylett

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 Changed 4 years ago by Tim Graham

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