Skip to content

improvement: Expand aggregate test covering rem expression #541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test/aggregate_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@
end
end

test "sum aggregates show the same value with filters on the sum vs filters on relationships" do

Check failure on line 932 in test/aggregate_test.exs

View workflow job for this annotation

GitHub Actions / ash-ci (14) / mix test

test sum aggregates show the same value with filters on the sum vs filters on relationships (AshSql.AggregateTest)

Check failure on line 932 in test/aggregate_test.exs

View workflow job for this annotation

GitHub Actions / ash-ci (16) / mix test

test sum aggregates show the same value with filters on the sum vs filters on relationships (AshSql.AggregateTest)

Check failure on line 932 in test/aggregate_test.exs

View workflow job for this annotation

GitHub Actions / ash-ci (15) / mix test

test sum aggregates show the same value with filters on the sum vs filters on relationships (AshSql.AggregateTest)
post =
Post
|> Ash.Changeset.for_create(:create, %{title: "title"})
Expand Down Expand Up @@ -957,6 +957,16 @@

assert %{sum_of_popular_comment_rating_scores_2: 80} =
values

values =
post
|> Ash.load!([
:sum_of_odd_comment_rating_scores
])
|> Map.take([:sum_of_odd_comment_rating_scores])

assert %{sum_of_popular_comment_rating_scores_2: 120} =
values
end

test "can't define multidimensional array aggregate types" do
Expand Down
4 changes: 4 additions & 0 deletions test/support/resources/post.ex
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,10 @@ defmodule AshPostgres.Test.Post do
filter(expr(score > 5))
end

sum :sum_of_odd_comment_rating_scores, [:comments, :ratings], :score do
filter(expr(rem(score, 2) == 1))
end

sum(:sum_of_popular_comment_rating_scores_2, [:comments, :popular_ratings], :score)

sum :sum_of_comment_likes_called_match, :comments, :likes do
Expand Down
Loading