#29527: Multi-column comparisons
-----------------------------------------+--------------------------------
               Reporter:  Ryan Hiebert   |          Owner:  nobody
                   Type:  Uncategorized  |         Status:  new
              Component:  Uncategorized  |        Version:  2.0
               Severity:  Normal         |       Keywords:  QuerySet.extra
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+--------------------------------
 Multi-column comparisons

 In order to implement keyset pagination, AKA the seek method, across
 multiple fields including ordering on non-unique fields, I'm wanting to
 write a PostgreSQL that compares multiple fields in an ordered fashion. To
 my knowledge this isn't possible with the current ORM syntax. My
 particular use-case further complicates this by also wanting a subquery in
 order to avoid serializing more than the unique key in the response.
 Here's a generic example where clause that mirrors my use-case:

 {{{#!sql
 (a,b,c,id) > (SELECT a,b,c,id FROM mytable WHERE id = ?)
 }}}

 What this does special is account for all of the columns when making the
 comparison. So it will only compare the id column if all of the a, b, and
 c columns are the same, to allow for exact indentification in an arbitrary
 ordering.

 In the PostgreSQL docs this feature is called Row Constructor Comparison,
 and the documentation is here: https://www.postgresql.org/docs/9.6/static
 /functions-comparisons.html#ROW-WISE-COMPARISON.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29527>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/054.43ad730db1c7294ad2dd7a97fd423678%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to