fix: Aggregation and Union __bool__ always returning True#1314
Merged
dimitri-yatsenko merged 1 commit intopre/v2.0from Jan 9, 2026
Merged
fix: Aggregation and Union __bool__ always returning True#1314dimitri-yatsenko merged 1 commit intopre/v2.0from
dimitri-yatsenko merged 1 commit intopre/v2.0from
Conversation
The __bool__ methods were returning bool(cursor) instead of bool(cursor.fetchone()[0]), causing them to always return True regardless of whether the query result was empty. Added tests for Aggregation and Union __bool__ behavior: - test_aggregation_bool_with_results - test_aggregation_bool_empty - test_aggregation_bool_matches_len - test_union_bool_with_results - test_union_bool_empty - test_union_bool_matches_len Fixes #1234 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
cdc66aa to
71e553a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the
__bool__method forAggregationandUnionclasses which always returnedTrueregardless of whether the query result was empty.Problem
The
__bool__methods were missing.fetchone()[0]:self.connection.query()returns a cursor object, andbool(cursor)is alwaysTruebecause the cursor object itself is truthy. The actual query result (0 or 1) was never fetched.Fix
Test
Closes
__bool__returns True when empty #1234🤖 Generated with Claude Code