Skip to content

Commit

Permalink
feat(query): improve unique orderBy error message (#515)
Browse files Browse the repository at this point in the history
  • Loading branch information
soutot authored and benjie committed Aug 31, 2019
1 parent 5fae076 commit 29d87da
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/graphile-build-pg/src/queryFromResolveDataFactory.js
Expand Up @@ -310,10 +310,12 @@ exists(
queryBuilder.whereBound(sql.fragment`false`, isAfter);
}
const orderByExpressionsAndDirections = queryBuilder.getOrderByExpressionsAndDirections();
if (
orderByExpressionsAndDirections.length > 0 &&
queryBuilder.isOrderUnique()
) {
if (orderByExpressionsAndDirections.length > 0) {
if (!queryBuilder.isOrderUnique()) {
throw new Error(
"The order supplied is not unique, so before/after cursors cannot be used. Please ensure the supplied order includes all the columns from the primary key or a unique constraint."
);
}
const rawPrefixes = cursorValue.slice(0, cursorValue.length - 1);
const rawCursors = cursorValue[cursorValue.length - 1];
if (rawPrefixes.length !== getPgCursorPrefix().length) {
Expand Down

0 comments on commit 29d87da

Please sign in to comment.