Skip to content

feat: add HAVING clause support to QueryBuilder - #24

Merged
codeasier merged 1 commit into
mainfrom
feat/query-builder-having
Apr 17, 2026
Merged

codeasier merged 1 commit into
mainfrom
feat/query-builder-having

Conversation

@codeasier

Copy link
Copy Markdown
Owner

📝 Description

Add HAVING clause support to QueryBuilder:

  • New having(condition) method for GROUP BY filtering
  • Integrated into build() between GROUP BY and ORDER BY
  • Multiple HAVING conditions joined with AND
  • reset() now clears HAVING state

Usage:

builder.from_table("blocks") \
    .columns("device_id", "COUNT(*) as cnt") \
    .group_by("device_id") \
    .having(GreaterThan("COUNT(*)", 100)) \
    .build()
# SELECT device_id, COUNT(*) as cnt FROM blocks GROUP BY device_id HAVING (COUNT(*) > ?)

🔗 Related Issue

Fixes #14

🧪 Testing

  • Tests added — 4 new test cases (single HAVING, multiple HAVING, full query, reset)
  • Manual testing completed

✅ Checklist

  • Code follows project guidelines
  • No new warnings introduced
  • Changes tested locally

Add a having() method for GROUP BY filtering and integrate
HAVING into the build() method (between GROUP BY and ORDER BY).
Includes tests for single/multiple HAVING conditions, full query
composition, and reset clearing HAVING state.

Closes #14
@codeasier
codeasier merged commit 8499ecc into main Apr 17, 2026
5 checks passed
@codeasier
codeasier deleted the feat/query-builder-having branch April 17, 2026 12:53
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.

[FEATURE] QueryBuilder 缺少 HAVING 子句支持

1 participant