feat: add Ash.Query.where/2 as non-macro alternative to filter/2#2666
Open
nallwhy wants to merge 2 commits into
Open
feat: add Ash.Query.where/2 as non-macro alternative to filter/2#2666nallwhy wants to merge 2 commits into
nallwhy wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Ash.Query.where/2 as a function-based (non-macro) alternative to Ash.Query.filter/2, intended to support keyword/map filter syntax without requiring require Ash.Query.
Changes:
- Introduces
Ash.Query.where/2and delegates filtering todo_filter/3. - Adds unit tests covering keyword and map syntax, filter combination, and no-op behavior for
nil/[].
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/ash/query/query.ex | Adds where/2 with docs/spec as a non-macro entrypoint to filtering. |
| test/filter/filter_test.exs | Adds tests for where/2 behavior (keyword/map, combining, nil/empty no-op). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
57be90d to
54afcdc
Compare
zachdaniel
reviewed
Apr 10, 2026
|
|
||
| Passing `nil` is a no-op, which is useful for conditional filtering in pipelines. | ||
|
|
||
| The filter is applied as an "and" to any filters currently on the query. |
Contributor
There was a problem hiding this comment.
So the concept here isn't that we only support the data structure format, thats just how it works by default. However you can do import Ash.Expr at which point you can do Ash.Query.where(expr(...)). That gives us one single function to use that does both expressions and non-expressions 😄
54afcdc to
31e2949
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.
Contributor checklist
Leave anything that you believe does not apply unchecked.
Summary
Ash.Query.where/2as a non-macro alternative toAsh.Query.filter/2do_filter/3functionCloses #1092