Skip to content

Commit d2657c1

Browse files
committed
fix: handle double select issue
chore: update for 1.18
1 parent 056979c commit d2657c1

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

.tool-versions

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
erlang 27.0.1
2-
elixir 1.18.0-rc.0-otp-27
2+
elixir 1.18.0-otp-27

lib/data_layer.ex

+7-4
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,7 @@ defmodule AshPostgres.DataLayer do
11091109
data_layer_query =
11101110
data_layer_query
11111111
|> Ecto.Query.exclude(:distinct)
1112+
|> Ecto.Query.exclude(:select)
11121113

11131114
if query.__ash_bindings__[:__order__?] do
11141115
{:ok,
@@ -1149,10 +1150,12 @@ defmodule AshPostgres.DataLayer do
11491150

11501151
case lateral_join_source_query(query, source_query) do
11511152
{:ok, data_layer_query} ->
1153+
data_layer_query = Ecto.Query.exclude(data_layer_query, :select)
1154+
11521155
through_resource
11531156
|> Ash.Query.new()
11541157
|> 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]
11561159
})
11571160
|> Ash.Query.set_context(through_relationship.context)
11581161
|> Ash.Query.do_filter(through_relationship.filter)
@@ -1168,6 +1171,7 @@ defmodule AshPostgres.DataLayer do
11681171
end
11691172
|> case do
11701173
{:ok, through_query} ->
1174+
through_query = Ecto.Query.exclude(through_query, :select)
11711175
if query.__ash_bindings__[:__order__?] do
11721176
subquery =
11731177
subquery(
@@ -1180,7 +1184,7 @@ defmodule AshPostgres.DataLayer do
11801184
source_query,
11811185
relationship.through
11821186
),
1183-
as: ^data_layer_query.__ash_bindings__.current,
1187+
as: ^Map.get(data_layer_query, :__ash_bindings__)[:current],
11841188
on:
11851189
field(through, ^destination_attribute_on_join_resource) ==
11861190
field(destination, ^destination_attribute),
@@ -1197,7 +1201,6 @@ defmodule AshPostgres.DataLayer do
11971201
)
11981202
)
11991203

1200-
data_layer_query = Ecto.Query.exclude(data_layer_query, :distinct)
12011204

12021205
{:ok,
12031206
from(source in data_layer_query,
@@ -1220,7 +1223,7 @@ defmodule AshPostgres.DataLayer do
12201223
source_query,
12211224
relationship.through
12221225
),
1223-
as: ^data_layer_query.__ash_bindings__.current,
1226+
as: ^Map.get(data_layer_query, :__ash_bindings__)[:current],
12241227
on:
12251228
field(through, ^destination_attribute_on_join_resource) ==
12261229
field(destination, ^destination_attribute),

0 commit comments

Comments
 (0)