Skip to content

feat: add Ash.Query.where/2 as non-macro alternative to filter/2#2666

Open
nallwhy wants to merge 2 commits into
ash-project:mainfrom
nallwhy:feat/query-where-non-macro-filter
Open

feat: add Ash.Query.where/2 as non-macro alternative to filter/2#2666
nallwhy wants to merge 2 commits into
ash-project:mainfrom
nallwhy:feat/query-where-non-macro-filter

Conversation

@nallwhy

@nallwhy nallwhy commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

Summary

  • Add Ash.Query.where/2 as a non-macro alternative to Ash.Query.filter/2
  • Delegates to the existing do_filter/3 function

Closes #1092

Copilot AI review requested due to automatic review settings April 8, 2026 09:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/2 and delegates filtering to do_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.

Comment thread lib/ash/query/query.ex
@nallwhy nallwhy force-pushed the feat/query-where-non-macro-filter branch from 57be90d to 54afcdc Compare April 8, 2026 15:04
Comment thread lib/ash/query/query.ex

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 😄

@nallwhy nallwhy force-pushed the feat/query-where-non-macro-filter branch from 54afcdc to 31e2949 Compare May 11, 2026 08:55
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.

Non-macro alternative to Ash.Query.filter

3 participants