Skip to content

Conversation

@ken-kost
Copy link
Contributor

@ken-kost ken-kost commented May 7, 2025

#2012

Not sure how correct this is regarding implementation details,.
Also I feel the test is misplaced, but it felt most convenient to make the test in that file.

Contributor checklist

  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

@zachdaniel
Copy link
Contributor

We will also have to ensure that in ash_sql in join.ex when we build the related subquery that we add a limit, and test this against things like filter(related.foo == bar) that the limit is applied in that context (we may need to do some work to detect said limit there 😄)

@ken-kost
Copy link
Contributor Author

ken-kost commented May 8, 2025

We will also have to ensure that in ash_sql in join.ex when we build the related subquery that we add a limit, and test this against things like filter(related.foo == bar) that the limit is applied in that context (we may need to do some work to detect said limit there 😄)

Could you expand on this? What would be a failing test example? The test should be in ash I assume.
From line 370 there is:

    |> Ash.Query.unset([:sort, :distinct, :select, :limit, :offset])
    |> handle_attribute_multitenancy(tenant)
    |> hydrate_refs(context[:private][:actor])
    |> then(fn query ->
      if sort? do
        Ash.Query.sort(query, relationship.sort)
      else
        Ash.Query.unset(query, :sort)
      end
    end)

should limit check be made somewhere there?

@ken-kost ken-kost requested a review from zachdaniel May 8, 2025 13:50
@zachdaniel zachdaniel merged commit 347564b into ash-project:main May 9, 2025
8 checks passed
@zachdaniel
Copy link
Contributor

🚀 Thank you for your contribution! 🚀

For the testing, what I was getting at is that we should now go and confirm via tests in ash_postgres that ash_sql does the right thing with these relationships, specifically when used in filters. i.e Ash.Query.filter(query, top_2_posts.name == "foo") (just an example)

@ken-kost
Copy link
Contributor Author

ken-kost commented May 9, 2025

Alright, I'll try it out. 👍

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