Skip to content

Fix ONLY_FULL_GROUP_BY violations in getCount() and Legacy GROUP BY tests#278

Open
opengeek wants to merge 1 commit intomodxcms:3.xfrom
opengeek:fix/190-groupby-only-full
Open

Fix ONLY_FULL_GROUP_BY violations in getCount() and Legacy GROUP BY tests#278
opengeek wants to merge 1 commit intomodxcms:3.xfrom
opengeek:fix/190-groupby-only-full

Conversation

@opengeek
Copy link
Copy Markdown
Member

What changed and why

Closes #190. MySQL 8.0 enforces ONLY_FULL_GROUP_BY by default. Two pre-existing violations caused all MySQL CI jobs to fail after upgrading the CI service image to mysql:8.0 (PR #277).

Files and methods changed

  • src/xPDO/xPDO.phpxPDO::getCount(): replaced $query->select($expr) with $query->select('1') so the subquery inner SELECT is always GROUP BY-compliant.
  • test/xPDO/Legacy/Om/xPDOQueryHavingTest.phptestHavingWithGroupBy(): added missing id and color columns to GROUP BY to match the implicit SELECT *.
  • test/xPDO/Legacy/Om/xPDOQueryLimitTest.phptestLimitWithGroupBy(): added missing id and name columns to GROUP BY for the same reason.

Cross-driver impact

The getCount() fix is universal (all drivers). The test fixes are MySQL-8-triggered but correct for all drivers that enforce GROUP BY strictness.

Test coverage

SQLite suite passing: 35 tests, 35 assertions. MySQL CI will verify against mysql:8.0 in PR #277 after this merges to 3.x.

Breaking change assessment

No public API change. getCount() return value is unchanged — SELECT 1 produces the same row count as SELECT {pk} for the purpose of the outer COUNT(*). Safe for patch-level consumers.

Contributors

Reported via CI failures on PR #277.

@opengeek opengeek force-pushed the fix/190-groupby-only-full branch from ab09aa1 to 3763642 Compare March 28, 2026 20:58
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

Successfully merging this pull request may close these issues.

[MySQL8] groupby sort issue

1 participant