Opened 14 years ago

Closed 14 years ago

#15028 closed (worksforme)

1.2.4 breaks queryset.extra(select={'__double_underscore_field': ...})

Reported by: Craig de Stigter Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

In 1.2.3 this worked fine:

qs = qs.extra(select={'__foo': "1"}).order_by('__foo')

Now in 1.2.4 I get:

FieldError at /test/
Cannot resolve keyword '' into field. Choices are [...]

I believe the solution is to change django/db/models/sql/compiler.py#L371

pieces = name.split(LOOKUP_SEP)

to

pieces = filter(None, name.split(LOOKUP_SEP))

Change History (3)

comment:1 by Craig de Stigter, 14 years ago

Actually.. that solution is munted since it strips off the underscores :(

Perhaps a regex fix?

We've already worked around this with s/foo/_foo/ ...

comment:2 by Craig de Stigter, 14 years ago

Has patch: unset
Patch needs improvement: set

comment:3 by Russell Keith-Magee, 14 years ago

Resolution: worksforme
Status: newclosed

I can't reproduce this problem on 1.2.3, 1.2.4 or trunk. If you can provide a more complete example that fails, feel free to reopen.

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