Repository navigation
Conversation
…ROWS MySQL 8.4 удалил SQL_CALC_FOUND_ROWS: запросы с &setTotal=`1` падали синтаксисом, а FOUND_ROWS() возвращал 0. - setTotal(): SELECT COUNT(*) FROM (<тот же SELECT без LIMIT/OFFSET>) AS _pdo_total - семантика GROUP BY / HAVING / DISTINCT идентична прежней FOUND_ROWS() - prepend SQL_CALC_FOUND_ROWS в addSelects() удален - юнит-тест SetTotalCountTest (обертка, срез LIMIT, гейт setTotal=0)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #38 +/- ##
============================================
+ Coverage 26.66% 27.10% +0.43%
+ Complexity 1165 1163 -2
============================================
Files 18 18
Lines 3011 3011
============================================
+ Hits 803 816 +13
+ Misses 2208 2195 -13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Проблема
pdoFetchсчиталtotalдля пагинации черезSQL_CALC_FOUND_ROWS+SELECT FOUND_ROWS():addSelects()prepend-илSQL_CALC_FOUND_ROWSк первой частиSELECTпри&setTotal=1``;setTotal()читалFOUND_ROWS().MySQL 8.4 удалил
SQL_CALC_FOUND_ROWS(deprecated с 8.0.17): на 8.4 запрос с&setTotal=1`` падает синтаксической ошибкой, а на строках без негоFOUND_ROWS()возвращает `0` — пагинация pdoPage ломается (одна страница, `[[+total]] = 0`).Архитектурный близнец для MODX 2.x: modx-pro/pdoTools#405.
Решение (Core First)
setTotal()считает total тем же самымSELECT, обернутым в производную таблицу:LIMIT/OFFSETсрезается, поэтому count соответствует полному (безлимитному) набору — семантика идентична прежнейFOUND_ROWS().GROUP BY/HAVING/DISTINCTсохраняются автоматически (в отличие отCOUNT(DISTINCT col), который ломается наHAVING).SQL_CALC_FOUND_ROWSтоже считал весь безлимитный результат.Совместимость
&setTotalи плейсхолдер[[+totalVar]]не меняются.return=sqlбольше не показываетSQL_CALC_FOUND_ROWSв тексте запроса.changelog.txt.Тесты и парный PR
tests/Unit/Fetch/SetTotalCountTest.php— обертка derived-table, срезLIMIT/OFFSET, отсутствиеSQL_CALC_FOUND_ROWS, гейт&setTotal=0``, запись в[[+totalVar]]. Unit suite: 119 tests OK.