@@ -1109,6 +1109,7 @@ defmodule AshPostgres.DataLayer do
1109
1109
data_layer_query =
1110
1110
data_layer_query
1111
1111
|> Ecto.Query . exclude ( :distinct )
1112
+ |> Ecto.Query . exclude ( :select )
1112
1113
1113
1114
if query . __ash_bindings__ [ :__order__? ] do
1114
1115
{ :ok ,
@@ -1149,10 +1150,12 @@ defmodule AshPostgres.DataLayer do
1149
1150
1150
1151
case lateral_join_source_query ( query , source_query ) do
1151
1152
{ :ok , data_layer_query } ->
1153
+ data_layer_query = Ecto.Query . exclude ( data_layer_query , :select )
1154
+
1152
1155
through_resource
1153
1156
|> Ash.Query . new ( )
1154
1157
|> Ash.Query . put_context ( :data_layer , % {
1155
- start_bindings_at: data_layer_query . __ash_bindings__ . current
1158
+ start_bindings_at: Map . get ( data_layer_query , : __ash_bindings__) [ : current]
1156
1159
} )
1157
1160
|> Ash.Query . set_context ( through_relationship . context )
1158
1161
|> Ash.Query . do_filter ( through_relationship . filter )
@@ -1168,6 +1171,7 @@ defmodule AshPostgres.DataLayer do
1168
1171
end
1169
1172
|> case do
1170
1173
{ :ok , through_query } ->
1174
+ through_query = Ecto.Query . exclude ( through_query , :select )
1171
1175
if query . __ash_bindings__ [ :__order__? ] do
1172
1176
subquery =
1173
1177
subquery (
@@ -1180,7 +1184,7 @@ defmodule AshPostgres.DataLayer do
1180
1184
source_query ,
1181
1185
relationship . through
1182
1186
) ,
1183
- as: ^ data_layer_query . __ash_bindings__ . current ,
1187
+ as: ^ Map . get ( data_layer_query , : __ash_bindings__) [ : current] ,
1184
1188
on:
1185
1189
field ( through , ^ destination_attribute_on_join_resource ) ==
1186
1190
field ( destination , ^ destination_attribute ) ,
@@ -1197,7 +1201,6 @@ defmodule AshPostgres.DataLayer do
1197
1201
)
1198
1202
)
1199
1203
1200
- data_layer_query = Ecto.Query . exclude ( data_layer_query , :distinct )
1201
1204
1202
1205
{ :ok ,
1203
1206
from ( source in data_layer_query ,
@@ -1220,7 +1223,7 @@ defmodule AshPostgres.DataLayer do
1220
1223
source_query ,
1221
1224
relationship . through
1222
1225
) ,
1223
- as: ^ data_layer_query . __ash_bindings__ . current ,
1226
+ as: ^ Map . get ( data_layer_query , : __ash_bindings__) [ : current] ,
1224
1227
on:
1225
1228
field ( through , ^ destination_attribute_on_join_resource ) ==
1226
1229
field ( destination , ^ destination_attribute ) ,
0 commit comments