Skip to content

test: added regression test for aggregate with action with modify query #597

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

Closed
wants to merge 1 commit into from
Closed
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
11 changes: 11 additions & 0 deletions test/aggregate_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1667,4 +1667,15 @@
Ash.Query.filter_input(AshPostgres.Test.StandupClub, filter)
|> Ash.read!(load: [:punchline_count])
end

@tag :regression
test "aggregates with modify_query works" do

Check failure on line 1672 in test/aggregate_test.exs

View workflow job for this annotation

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

test aggregates with modify_query works (AshSql.AggregateTest)

Check failure on line 1672 in test/aggregate_test.exs

View workflow job for this annotation

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

test aggregates with modify_query works (AshSql.AggregateTest)

Check failure on line 1672 in test/aggregate_test.exs

View workflow job for this annotation

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

test aggregates with modify_query works (AshSql.AggregateTest)
assert_raise Ash.Error.Unknown, ~r/^modifying query!$/, fn ->
Post
|> Ash.Query.load([
:count_comments_with_modify_query
])
|> Ash.read_one!()
end
end
end
15 changes: 15 additions & 0 deletions test/support/resources/comment.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ defmodule AshPostgres.Test.Comment do

change(manage_relationship(:rating, :ratings, on_missing: :ignore, on_match: :create))
end

read :with_modify_query do
modify_query({AshPostgres.Test.Comment.ModifyQuery, :modify, []})
end
end

attributes do
Expand Down Expand Up @@ -104,3 +108,14 @@ defmodule AshPostgres.Test.Comment do
)
end
end

defmodule AshPostgres.Test.Comment.ModifyQuery do
@moduledoc """
Raises when modifying query so we can assert
this code path is called.
"""

def modify(_ash_query, _ecto_query) do
raise "modifying query!"
end
end
4 changes: 4 additions & 0 deletions test/support/resources/post.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,10 @@ defmodule AshPostgres.Test.Post do
end

first(:author_profile_description, :author, :description)

count :count_comments_with_modify_query, :comments do
read_action(:with_modify_query)
end
end
end

Expand Down
Loading