Skip to content

feat(orm): add exists() to QueryBuilder#90

Merged
bedus-creation merged 2 commits into
mainfrom
feat/orm-exists-method
Jun 6, 2026
Merged

feat(orm): add exists() to QueryBuilder#90
bedus-creation merged 2 commits into
mainfrom
feat/orm-exists-method

Conversation

@bedus-creation

Copy link
Copy Markdown
Contributor

Summary

  • Adds async def exists() -> bool to QueryBuilder
  • Delegates to COUNT(*) via the existing aggregate() path — no model hydration
  • Fully chain-friendly: await User.where("email", x).exists()

Changes

  • builder.py — 4-line addition after count(), reusing aggregate("COUNT", "*")
  • test_sqlite_builder_exists.py — 4 new test cases covering True match, False no-match, bare table query, and empty-table case

Test plan

  • test_exists_returns_true_when_record_matcheswhere().exists()True
  • test_exists_returns_false_when_no_matchwhere().exists()False
  • test_exists_true_with_no_where_clause — bare query().exists() on seeded table → True
  • test_exists_false_on_empty_tablequery().exists() after wipe → False

All 4 pass ✅

🤖 Generated with Claude Code

bedus-creation and others added 2 commits June 5, 2026 20:28
Adds an async `exists()` method that returns True if any record matches
the current query, False otherwise. Delegates to COUNT(*) for efficiency
— no model hydration. Supports full chaining: `await User.where(...).exists()`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bedus-creation bedus-creation merged commit 4d19ae9 into main Jun 6, 2026
3 checks passed
@bedus-creation bedus-creation deleted the feat/orm-exists-method branch June 8, 2026 07:34
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.

1 participant