Skip to content

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

Merged
opengeek merged 1 commit intomodxcms:3.xfrom
opengeek:fix/190-groupby-only-full
Apr 4, 2026
Merged

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

Conversation

@opengeek
Copy link
Copy Markdown
Member

@opengeek opengeek commented Mar 28, 2026

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.

AI Disclosure

This fix was developed using an AI-assisted workflow. AI agents (Claude) wrote the code, tests, and initial code review under the direction of the project maintainer (@opengeek), who reviewed the final diff, validated the approach, and takes responsibility for the submission.

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
@opengeek opengeek merged commit 0a22feb into modxcms:3.x Apr 4, 2026
27 checks passed
@opengeek opengeek deleted the fix/190-groupby-only-full branch April 4, 2026 00:00
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