Opened 5 years ago

Closed 3 years ago

#14757 closed Bug (wontfix)

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

Reported by: mikeshultz 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 jpaulett 4 years ago.
Add example using both tables and where in Queryset.extra()
querysets.txt.diff (979 bytes) - added by BernhardEssl 4 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 5 years ago by gabrielhurley

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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

Changed 4 years ago by jpaulett

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

comment:2 Changed 4 years ago by jpaulett

  • 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 4 years ago by anonymous

  • Severity set to Normal
  • Type set to Bug

comment:4 Changed 4 years ago by SmileyChris

  • 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 4 years ago by SmileyChris

  • Easy pickings set
  • Patch needs improvement set

Changed 4 years ago by BernhardEssl

comment:6 Changed 4 years ago by BernhardEssl

  • UI/UX unset

Added a patch with params using in the where clause.

comment:7 Changed 4 years ago by krzysiumed

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 3 years ago by jaylett

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 3 years ago by timo

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

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