Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support Through Relationships #1780

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

ken-kost
Copy link
Contributor

@ken-kost ken-kost commented Feb 8, 2025

#72

Contributor checklist

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

@ken-kost
Copy link
Contributor Author

ken-kost commented Feb 8, 2025

is this a feat or enhancement? 🤔😅

@zachdaniel
Copy link
Contributor

This would be a feature 😄 . Will have to review next week.

@ken-kost ken-kost force-pushed the feat-relationships-enable-through-option branch from 39b2366 to d301173 Compare February 9, 2025 09:11
@ken-kost ken-kost marked this pull request as draft February 9, 2025 10:07
@@ -1191,6 +1251,9 @@ defmodule Ash.Actions.Read.Relationships do
has_page? = query.page not in [nil, false]

cond do
is_list(relationship.through) ->
false
Copy link
Contributor

Choose a reason for hiding this comment

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

So this will actually be the way that we enable data layers to join through relationships. So this should return true if the data layer can :lateral_join_through_relationships or something. For now, nothing will implement this, so we can leave it as a stub and talk about that implementation later. It is actually quite complex to do 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

In fact...yeah returning false makes sense here, never mind. When its time to support doing this in an optimized way in the data layer, then we'd return true here.

@@ -612,6 +623,50 @@ defmodule Ash.Actions.Read.Relationships do
)
end

defp load_related_records(records, through, cardinality) do
load_statement =
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to pass through the actor, tenant, authorize? and tracer options from the parent call to this call.

Additionally, we should call Ash.load with the list of records, not each individual record. That will be much more optimized.

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