From d8d69d3fb68ae989dee38b7e5b65feec2abc91d0 Mon Sep 17 00:00:00 2001 From: ken-kost <kenneth.kostresevic@gmail.com> Date: Fri, 2 May 2025 17:14:28 +0200 Subject: [PATCH] Expand aggregate test covering rem expression --- test/aggregate_test.exs | 10 ++++++++++ test/support/resources/post.ex | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/test/aggregate_test.exs b/test/aggregate_test.exs index bd34f579..e3ad5fa1 100644 --- a/test/aggregate_test.exs +++ b/test/aggregate_test.exs @@ -957,6 +957,16 @@ defmodule AshSql.AggregateTest do 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 diff --git a/test/support/resources/post.ex b/test/support/resources/post.ex index 6ddcb160..63890c95 100644 --- a/test/support/resources/post.ex +++ b/test/support/resources/post.ex @@ -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