﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
29527	Multi-column comparisons	Ryan Hiebert	nobody	"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."	New feature	closed	Database layer (models, ORM)	2.0	Normal	needsinfo	QuerySet.extra		Unreviewed	0	0	0	0	0	0
