Opened 10 years ago

Closed 10 years ago

#23460 closed Bug (fixed)

Allow a literal `%s` to be passed through extra select

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

Description (last modified by Matt Robenolt)

Right now, if you try and do something like this:

Foo.objects.extra(select={'foo': "'%%s"'})

or

Foo.objects.extra(select={'foo': '"%s"'})

Ultimately add_extra raises a StopIteration while iterating over param_iter since there aren't actually any arguments to format.

It's expected to allow %%s as an escape sequence.

See: https://github.com/django/django/pull/3209 for patch.

Change History (7)

comment:1 by Matt Robenolt, 10 years ago

Description: modified (diff)

comment:2 by Matt Robenolt, 10 years ago

Description: modified (diff)

comment:3 by Matt Robenolt, 10 years ago

Description: modified (diff)

comment:4 by Matt Robenolt, 10 years ago

Type: UncategorizedBug

comment:5 by Tim Graham, 10 years ago

Patch needs improvement: set
Triage Stage: UnreviewedAccepted

comment:6 by Tim Graham, 10 years ago

Patch needs improvement: unset

comment:7 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: newclosed

In ef5f9b6ae8c873927aa6047f5f9d1d902a0c2177:

Fixed #23460 -- Added literal %s support to extra() QuerySets.

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