-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when ordering by column in related table when using custom query #25
Comments
Does this only happen on custom queries, or does it affect tables too? It's very hard to guarantee unique ordering with functions, and I'd recommend against custom ordering over large result sets from custom queries/computed columns for performance reasons. |
It works perfectly when using the base queries provided by PostGraphile, the problem only occurs when we try to do it with this custom query. |
Can you add |
But if the ordering that you've specified is unique, then this plugin needs to indicate so. |
I have tested adding ID_ASC to the list and it does seem to have fixed the problem. It does seem that, at least in the case I am testing, the ordering I specify should be unique, if I'm understanding everything correctly. Below is a simple reproduction of the setup we have:
The only real difference between this example and the one above is that the foreign key |
This one with a unique constraint would be unique, yes. Without wouldn't be. This is equivalent to just sorting by |
Yes, exactly, and that is the strange thing when querying a custom query, the pagination works correctly when ordering by But like we found out before it does work correctly when ordering by both |
Basically the plugin needs to declare that the order is unique, like we do in core here: |
I'm submitting a ...
PostGraphile version: [email protected]
pg-order-by-related version: @graphile-contrib/[email protected]
Minimal SQL file that can be loaded into a clean database:
Query:
CLI command:
Current behavior:
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."
Expected behavior:
Result will be ordered by the column from the related table.
The text was updated successfully, but these errors were encountered: