Skip to content
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

Cursor pagination does not work with orderBy() using a sub query #38447

Closed
shadoWalker89 opened this issue Aug 19, 2021 · 3 comments
Closed

Cursor pagination does not work with orderBy() using a sub query #38447

shadoWalker89 opened this issue Aug 19, 2021 · 3 comments

Comments

@shadoWalker89
Copy link
Contributor

  • Laravel Version: 8.52.0
  • PHP Version: 8.0.3
  • Database Driver & Version: maria db 10.3.12

Description:

When doing an orderBy using a sub query and using cursor pagination i get this error

array_flip(): Can only flip string and integer values, entry skipped

The error is coming from here

By the way using the same query with other paginators works perfectly fine

Steps To Reproduce:

Model::orderBy(
SomeOtherModel::select('name')->whereColumn('model.id', 'some_other_model.model_id')
)
@driesvints
Copy link
Member

This isn't supported. A cursor based paginator needs a column with unique values to order.

@shadoWalker89
Copy link
Contributor Author

@driesvints From my understanding cursor pagination does not stop you from using additional order by other then the primary key order by.

So this is the query that i'm aiming for

select * from coursesorder byidasc, (selectnamefromsubjectswheresubjects.id=courses.subject_id) asc limit 16

Having two order by is not supported ?

@driesvints
Copy link
Member

Sub queries aren't supported no. You're always free to attempt to make it work through a pr if you wish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants