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

Pagination Sort #11

Open
mklappen opened this issue Apr 13, 2016 · 5 comments
Open

Pagination Sort #11

mklappen opened this issue Apr 13, 2016 · 5 comments

Comments

@mklappen
Copy link

Hate to open another issue, but just noticed when implementing pagination in my app that the cakephp paginator sort does not seem to be passed into the Oracle SQL that's created from driver.

The initial query passed from model sorts correctly and adds the "Order By" in the inner select query as expected. But the Order By gets dropped when I try to sort by the cakePHP Paginator Sort option that's on one of the columns. Will try to trace back where it's getting dropped.
.

@snelg
Copy link
Owner

snelg commented Apr 13, 2016

Opening another issue is fine. I prefer that to having a single issue expand and evolve over time.
I can't re-create the problem. Sorting + Pagination is working as expected on my little test system. So it's not broken at the very basic level.
There could very easily still be something missing in my code, though. Some condition I didn't consider. If you can't figure out where the problem is, you can send me code examples (whatever you think is pertinent) and I'll see if I can figure it out.

@mklappen
Copy link
Author

hmm, thanks. Not sure on this, does your pagination example you tested contain any relationship/foreign key?
My table has a belongsTo/hasMany relationship so it's pulling a foreign key from another table/model.
So there's an INNER JOIN in the generated SQL both when page loads and when I click on a column to sort. Just that after clicking on column header to sort the ORDER BY not added into the SQL.

That's only thing I can think of now, but I honestly havent had a lot of time to look into it today. Will try to debug more and let you know, but may be a week before as I'm out of town next week.

Thanks!

@snelg
Copy link
Owner

snelg commented Apr 14, 2016

Ah, no I didn't test with relationships. I'll try that in a bit, but maybe you missed the "sortWhitelist" pagination thing:
http://book.cakephp.org/3.0/en/controllers/components/pagination.html#control-which-fields-used-for-ordering
Important quote on that page: "This option is required when you want to sort on any associated data"

@snelg
Copy link
Owner

snelg commented Apr 14, 2016

Yep, pretty sure that's your problem. Sorting on related table data works properly for me, but only when using the sortWhitelist as described in that link.

@mklappen
Copy link
Author

ah, yes you may be right... i don't think I did add sortWhitelist. away from computer now but will double check and post back when have access to my code. thanks again

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