Skip to content

bug: Add test verifying a bug in AshSql with has_many with limit and sort not respected in exists query filters#667

Merged
zachdaniel merged 1 commit intomainfrom
bug/exists-uses-limit-sort
Jan 29, 2026
Merged

bug: Add test verifying a bug in AshSql with has_many with limit and sort not respected in exists query filters#667
zachdaniel merged 1 commit intomainfrom
bug/exists-uses-limit-sort

Conversation

@sevenseacat
Copy link
Contributor

@sevenseacat sevenseacat commented Dec 26, 2025

This test currently fails, and the fix is in ash-project/ash_sql#198 :)

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

…and `sort` not respected in `exists` query filters
sevenseacat added a commit to ash-project/ash_sql that referenced this pull request Dec 26, 2025
…ry filters

Previously, the relationship limit was not being applied when using the relationship
in an `exists` query. After fixing that, then the limit was being applied in the
wrong place - it needs to be *inside* the exists check pre-filtering, instead
of outside it.

The test for this feature is in AshPostgres ash-project/ash_postgres#667 -
this code makes that test pass.
relationship_context: %{data_layer: %{table: "comment_ratings"}}
)

has_many :top_ratings, AshPostgres.Test.Rating do
Copy link
Contributor

Choose a reason for hiding this comment

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

Given the solution in ash_sql, would it be possible to add and test a relationship here that also has a parent/1 expression in its filter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's another issue I haven't quite managed to figure out, parents and exists seem to be a bit weird, filters in the wrong places

zachdaniel pushed a commit to ash-project/ash_sql that referenced this pull request Jan 29, 2026
…ry filters (#198)

Previously, the relationship limit was not being applied when using the relationship
in an `exists` query. After fixing that, then the limit was being applied in the
wrong place - it needs to be *inside* the exists check pre-filtering, instead
of outside it.

The test for this feature is in AshPostgres ash-project/ash_postgres#667 -
this code makes that test pass.
@zachdaniel zachdaniel merged commit c85f18b into main Jan 29, 2026
57 of 66 checks passed
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.

2 participants