-
-
Notifications
You must be signed in to change notification settings - Fork 48
Milestone
Description
Currently when using keyset pagination we might get to the edge case where key might be ambiguous column.
This might happen when we join tables, both have id column but in the select we expose only one of them:
SELECT
a.id as id
FROM table_a a
LEFT JOIN table_b b ON a.sub_id = b.sub_id
WHERE id > :id_previous
ORDER BY idIn this case postgresql will complain that id is ambiguous.
The solution is to add alias to key, so the column will be used in the WHERE/ORDER BY part of the query and alias is going to be used to take last value from previous results.
Alternatively we could dynamically add an alias to the query and then remove it once we retrieve the value from last row of previous batch.