Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitac0568b

Browse files
committed
feat: support named aggregates
1 parent52cc180 commitac0568b

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

‎lib/data_layer.ex‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ defmodule AshPostgres.DataLayer do
293293
defpadd_to_select(
294294
%{expr:{:merge,_,[first,{:%{},_,[{:aggregates,{:%{},[],fields}}]}]}}=select,
295295
binding,
296-
aggregate
296+
%{load:nil}=aggregate
297297
)do
298298
field=
299299
{:type,[],
@@ -319,6 +319,30 @@ defmodule AshPostgres.DataLayer do
319319
%{select|expr:{:merge,[],[first,{:%{},[],[{:aggregates,{:%{},[],new_fields}}]}]}}
320320
end
321321

322+
defpadd_to_select(
323+
%{expr:expr}=select,
324+
binding,
325+
%{load:load_as}=aggregate
326+
)do
327+
field=
328+
{:type,[],
329+
[
330+
{{:.,[],[{:&,[],[binding]},aggregate.name]},[],[]},
331+
Ash.Type.ecto_type(aggregate.type)
332+
]}
333+
334+
field_with_default=
335+
ifaggregate.default_valuedo
336+
{:coalesce,[],
337+
[
338+
field,
339+
aggregate.default_value
340+
]}
341+
end
342+
343+
%{select|expr:{:merge,[],[expr,{:%{},[],[{load_as,field_with_default}]}]}}
344+
end
345+
322346
defpadd_aggregate_to_subquery(query,resource,aggregate,binding)do
323347
new_joins=
324348
List.update_at(query.joins,binding-1,fnjoin->

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp