Skip to content

Commit 305b7cc

Browse files
committed
fix: use subqueries for join resources
1 parent a5d69cd commit 305b7cc

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/data_layer.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,11 +1189,11 @@ defmodule AshPostgres.DataLayer do
11891189
destination in query,
11901190
select_merge: %{__order__: over(row_number(), :order)},
11911191
join:
1192-
through in ^set_subquery_prefix(
1192+
through in subquery(set_subquery_prefix(
11931193
through_query,
11941194
source_query,
11951195
relationship.through
1196-
),
1196+
)),
11971197
as: ^through_binding,
11981198
on:
11991199
field(through, ^destination_attribute_on_join_resource) ==
@@ -1227,11 +1227,11 @@ defmodule AshPostgres.DataLayer do
12271227
from(
12281228
destination in query,
12291229
join:
1230-
through in ^set_subquery_prefix(
1230+
through in subquery(set_subquery_prefix(
12311231
through_query,
12321232
source_query,
12331233
relationship.through
1234-
),
1234+
)),
12351235
as: ^through_binding,
12361236
on:
12371237
field(through, ^destination_attribute_on_join_resource) ==

test/support/resources/post.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ defmodule AshPostgres.Test.Post do
533533
public?(true)
534534

535535
destination_attribute(:post_id)
536+
filter expr(not is_nil(post.id))
536537
end
537538

538539
many_to_many :co_authors, AshPostgres.Test.Author do

0 commit comments

Comments
 (0)