Skip to content

fix(schema): require groupBy when having is present - #58

Merged
kudima03 merged 4 commits into
mainfrom
fix/having-requires-groupby
Sep 24, 2026
Merged

kudima03 merged 4 commits into
mainfrom
fix/having-requires-groupby

Conversation

@kudima03

@kudima03 kudima03 commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closes #40. having filters aggregation groups, so it only makes sense alongside groupBy. The schema used to accept having on its own without complaint.

  • Added "dependentRequired": { "having": ["groupBy"] } to the root object. This draft 2020-12 keyword does the same job as the if/then proposed in the issue, in one line.
  • Added minItems: 1 to groupBy, so "groupBy": [] can't be used to get around the rule.
  • Added a CHANGELOG.md entry under [Unreleased] listing both changes as breaking, and updated README.md.

Verification

All 21 samples still validate. Scenario checks against samples/08_having.json:

Scenario Result
having + groupBy valid
having without groupBy invalid: 'groupBy' is a dependency of 'having'
neither valid
having + empty groupBy invalid: [] is too short

Release

This PR doesn't bump the version. When releasing, rename [Unreleased] in CHANGELOG.md to the new version and update version / $id in the schema. These changes tighten constraints, so the release needs a major bump.

🤖 Generated with Claude Code

kudima03 and others added 4 commits September 24, 2026 11:33
Add dependentRequired { having: [groupBy] } to the root object and
minItems: 1 on groupBy, so having without grouping (or with an empty
groupBy) fails validation. Bump version to 0.1.0-preview.1.0.0 and
update CHANGELOG and README.

Closes #40

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kudima03 kudima03 self-assigned this Sep 24, 2026
@kudima03
kudima03 merged commit 0a4e110 into main Sep 24, 2026
1 check passed
@kudima03
kudima03 deleted the fix/having-requires-groupby branch September 24, 2026 11:46
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.

Prevent having without groupBy at schema level

1 participant