Opened 9 years ago

Closed 9 years ago

#24814 closed Uncategorized (duplicate)

Unable to order_by an ArrayField element.

Reported by: Matthew Schinckel Owned by:
Component: contrib.postgres Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Matthew Schinckel)

It seems logical that, given a model Foo, with ArrayField bar, we should be able to (using the same rules for querying), perform:

    Foo.objects.order_by('bar__0')

However, this does not work. Is this something that _should_ be made to work?

It is possible to perform this query using an OrderBy(RawSQL()) thing, but that's a bit hard to figure out.

It's worth pointing out that the same limitation applies to Hstore fields, and will apply to JSON fields.

At the very least, this should perhaps be documented?

Change History (2)

comment:1 by Matthew Schinckel, 9 years ago

Description: modified (diff)

comment:2 by Matthew Schinckel, 9 years ago

Resolution: duplicate
Status: newclosed

Duplicates #24747.

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