stwe / DatatablesBundle

This Bundle integrates the jQuery DataTables plugin into your Symfony application.
355 stars 236 forks source link

Showing all entries does not work #961

Open knallcharge opened 4 years ago

knallcharge commented 4 years ago

Hi,

I'm having a strange error when trying to show all entries in a datatable. This is my length_menu: 'length_menu' => [[10, 25, 50, 100, -1], ['10', '25', '50', '100', 'All'], The dropdown shows the correct numbers and works for 10, 25, 50, 100 but not for "All" and it shows an error when reloading the page after setting the length to "All".

More detail: Loading the page with the page length set to "10" and then switching to "All" will only show 50 entries (while having 2,5k in my DB). The same applies to the other setting, the shown number is always "page_length * 5" (showing 125 when set to 25, reloading page, switching to "All", 250 with 50 and 500 with 100). (If I don't reload the page, the maximum number stays the same, e.g. reload page with "10", set to "All" will show 50, not reloading the page but setting the length to 25 first and the again to "All" will again only show 50.)

Then: While the above only applies while reloading the page with a number set in the dropdown, if I set the dropdown to "All" and then reload the page, the query is somehow broken, I get an "SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-5' at line 1" in the Symfony toolbar, the relevant part of the query being "ORDER BY m0_.id DESC LIMIT -5".

Can anybody reproduce this or lead me to a solution? Can't believe this has never happened to anybody, or is nobody using the "All"-option with page_length?

knallcharge commented 4 years ago

Looked further, because the factor 5 struck me and found something: I'm setting the pipeline in the AJAX options ('pipeline' => 5), removing this will resolve the issue (but of course disable ajax caching which I'd like to use). Still considering this a bug, so I'll leave this open.

Seb33300 commented 4 years ago

I was encountering issue when working with thousand of line and trying to display all on a SQL Server database.

The issue was fixed in Doctrine ORM 2.7.0 https://github.com/doctrine/orm/issues/7829

But maybe not related