chore: add tests for ash_sql #243 - #811
Merged
zachdaniel merged 1 commit intoAug 3, 2026
Merged
Conversation
Every existing combination test stops at two parts, which is the one shape where the order cannot be observed: two parts agree however they are grouped, and `union`/`except` share a precedence in SQL so they agree as well. Add a three-part case spanning two precedence levels — base, union, then intersect — where applying the parts in the order given and letting SQL's precedence regroup them produce different answers. A fourth record belongs to neither grouping, so reading the whole table cannot be mistaken for a pass. Fails against ash_sql 0.6.6 and passes with ash-project/ash_sql#NNN, which this reproduces.
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.
Contributor checklist
Leave anything that you believe does not apply unchecked.
Reproduction/regression test for: ash-project/ash_sql#244 (issue:
ash-project/ash_sql#243).
Ash.Query.combination_of/2applies its parts in the order given, each to the result ofeverything before it.
ash_sqlrenders them as a flat chain of set operations, so SQL's ownprecedence regroups a combination that spans more than one precedence level .
INTERSECT
binds tighter thanUNION/EXCEPT. The query then answers differently here than it does underAsh.DataLayer.Ets`.The test adds a three-part case to
test/combination_test.exs:base,union, thenintersect,where applying the parts in order and letting SQL regroup them give different answers. A fourth
record belongs to neither grouping, so reading the whole table cannot be mistaken for a pass.
Every existing combination test here stops at two parts, which is the one shape where the order
cannot be observed — two parts agree however they are grouped, and
union/exceptshare aprecedence in SQL so they agree too. That is why this has not surfaced.
mainis currently redindependently of this: 11 tests in
AshPostgres.AggregateReadActionTestfail onfc165f3eagainst released
ash_sql0.6.6, unrelated to combinations or to this change.