File tree 2 files changed +16
-12
lines changed
2 files changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -1182,18 +1182,26 @@ defmodule AshPostgres.DataLayer do
1182
1182
{ :ok , through_query } ->
1183
1183
through_query = Ecto.Query . exclude ( through_query , :select )
1184
1184
1185
+ through_query =
1186
+ if through_query . joins && through_query . joins != [ ] do
1187
+ subquery (
1188
+ set_subquery_prefix (
1189
+ through_query ,
1190
+ source_query ,
1191
+ relationship . through
1192
+ )
1193
+ )
1194
+ else
1195
+ through_query
1196
+ end
1197
+
1185
1198
if query . __ash_bindings__ [ :__order__? ] do
1186
1199
subquery =
1187
1200
subquery (
1188
1201
from (
1189
1202
destination in query ,
1190
1203
select_merge: % { __order__: over ( row_number ( ) , :order ) } ,
1191
- join:
1192
- through in subquery ( set_subquery_prefix (
1193
- through_query ,
1194
- source_query ,
1195
- relationship . through
1196
- ) ) ,
1204
+ join: through in ^ through_query ,
1197
1205
as: ^ through_binding ,
1198
1206
on:
1199
1207
field ( through , ^ destination_attribute_on_join_resource ) ==
@@ -1227,11 +1235,7 @@ defmodule AshPostgres.DataLayer do
1227
1235
from (
1228
1236
destination in query ,
1229
1237
join:
1230
- through in subquery ( set_subquery_prefix (
1231
- through_query ,
1232
- source_query ,
1233
- relationship . through
1234
- ) ) ,
1238
+ through in ^ through_query ,
1235
1239
as: ^ through_binding ,
1236
1240
on:
1237
1241
field ( through , ^ destination_attribute_on_join_resource ) ==
Original file line number Diff line number Diff line change @@ -533,7 +533,7 @@ defmodule AshPostgres.Test.Post do
533
533
public? ( true )
534
534
535
535
destination_attribute ( :post_id )
536
- filter expr ( not is_nil ( post . id ) )
536
+ filter ( expr ( not is_nil ( post . id ) ) )
537
537
end
538
538
539
539
many_to_many :co_authors , AshPostgres.Test.Author do
You can’t perform that action at this time.
0 commit comments