test: cover multi-hop exists aggregates and exists/2 over relationship paths - #843
Merged
zachdaniel merged 1 commit intoSep 2, 2026
Merged
Conversation
…p paths A multi-hop exists with a ref-less predicate (unfiltered exists aggregate, exists(path, true)) compiled to a subquery that only checked the first relationship in the path, wrongly returning true with zero related rows. Fixed in ash_sql by anchoring every hop of the path. Adds TwoHopExistsTest resources (Entry -> Bucket -> Item) and regression tests: zero-row multi-hop exists, three-hop chains broken at each level, a no_attributes? hop after a broken middle hop, and predicate scoping to the last resource in the path. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
🚀 Thank you for your contribution! 🚀 |
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.
Companion to ash-project/ash_sql#259 — regression tests for multi-hop
existswrongly returningtruewith zero related rows when the predicate has no refs (unfilteredexistsaggregates,exists(path, true)).What's added
New self-contained resources
AshPostgres.Test.TwoHopExistsTest.{Entry, Bucket, Item}(Entrybelongs_toBucket, Buckethas_manyItems, plus anentrybelongs_to and ano_attributes?relationship on Item), with tests appended to the existingdescribe "exists"block intest/aggregate_test.exs:exists/2are false with zero related rows (the original bug; also asserts the tail table appears in the generated SQL), and true with one related rowno_attributes?(on: true) hop later in the path — this one requires anchoring every hop, not just the lastnamecolumn; every row except the leaf is named to bait a wrong binding)Note on CI
These tests fail against ash_sql 0.7.1 from hex (that's the bug) and pass with ash-project/ash_sql#259 (
ASH_SQL_VERSION=local), where the full suite is green including all pre-existing exists/aggregate tests. This PR should land after/with the ash_sql fix.🤖 Generated with Claude Code