-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Edge case breaking Cursor Pagination #37400
Comments
@kamui545, cursor pagination needs the values of the columns to construct the query. So, I guess because of the name collision the model may not be hydrated with the value for cursor pagination to use. Perhaps you can alias the value and try using the alias in In case that doesn't work, it would be great if you could share the migrations/relationship method so that I can reproduce on my end. |
@paras-malhotra Yes aliasing was the first thing that came to my mind, sadly once using a cursor (browsing the next page) the app would crash because of SQL errors, it cannot find the alias. I just finished my repo: https://github.com/kamui545/laravel-cursor
You should be able to see something like this: I tried to cover every cases and highlighted the issues. Let me know if you need more information, I think the code speaks for itself and if I try to explain it myself I will end up confusing you 😂. I will continue investigating as well. Thanks ! |
I see in |
@paras-malhotra have you found time to look into this yet? |
@driesvints, not yet. I'll work on this before the end of the week and submit a PR if there's a good solution to the issue. |
Sorry to ping you again @paras-malhotra but did you already found a solution to this? |
@driesvints sorry to have not responded. Something urgent has come up. I'll definitely try and work on it this week. |
@paras-malhotra Don't worry about it 👍 |
Description:
It seems that the new Cursor Pagination from #37216 does not work well when specifying the table used in
orderBy
/latest
(when working with inner join / ambiguous columns).Edit: Actually, it seems like this is related to pivots
Steps To Reproduce:
I've got the following relationship on my
User
model, an user can hide other users:What I would like to do is displaying that list of hidden users, ordered by the latest added.
Simply done like that:
However, this does not work because of ambiguous columns, both
users
andhidden_profiles
havecreated_at
columns, so we have to give the proper table:This works, but sadly once you give him a cursor (browsing next page), it will break with the following error:
I will try to work on a patch or at least a repo / failing test to reproduce this easily as soon as I can.
@paras-malhotra Is this a limitation by design? Any idea where I should start?
The text was updated successfully, but these errors were encountered: