Skip to content
Merged
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
29 changes: 29 additions & 0 deletions test/aggregate_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
assert read_post.count_of_comments == 1
end

test "loading optimizable first aggregate with relationship filter does not cause binding errors" do

Check failure on line 105 in test/aggregate_test.exs

View workflow job for this annotation

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

test loading optimizable first aggregate with relationship filter does not cause binding errors (AshSql.AggregateTest)

Check failure on line 105 in test/aggregate_test.exs

View workflow job for this annotation

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

test loading optimizable first aggregate with relationship filter does not cause binding errors (AshSql.AggregateTest)

Check failure on line 105 in test/aggregate_test.exs

View workflow job for this annotation

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

test loading optimizable first aggregate with relationship filter does not cause binding errors (AshSql.AggregateTest)
org =
Organization
|> Ash.Changeset.for_create(:create, %{name: "The Org"})
Expand Down Expand Up @@ -1976,7 +1976,36 @@
end
end

test "load aggregate with select and sort on from_many relationship" do

Check failure on line 1979 in test/aggregate_test.exs

View workflow job for this annotation

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

test load aggregate with select and sort on from_many relationship (AshSql.AggregateTest)

Check failure on line 1979 in test/aggregate_test.exs

View workflow job for this annotation

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

test load aggregate with select and sort on from_many relationship (AshSql.AggregateTest)

Check failure on line 1979 in test/aggregate_test.exs

View workflow job for this annotation

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

test load aggregate with select and sort on from_many relationship (AshSql.AggregateTest)
author =
Author
|> Ash.Changeset.for_create(:create, %{first_name: "John", last_name: "Doe"})
|> Ash.create!()

post =
Post
|> Ash.Changeset.for_create(:create, %{title: "Test Post"})
|> Ash.Changeset.manage_relationship(:author, author, type: :append_and_remove)
|> Ash.create!()

Comment
|> Ash.Changeset.for_create(:create, %{title: "Test Comment"})
|> Ash.Changeset.manage_relationship(:post, post, type: :append_and_remove)
|> Ash.create!()

results =
Post
|> Ash.Query.filter(id == ^post.id)
|> Ash.Query.select([:id, :title])
|> Ash.Query.sort([{Ash.Sort.expr_sort(expr(latest_comment.created_at)), :desc}])
|> Ash.Query.load(:author_first_name)
|> Ash.read!()

assert Enum.count(results) == 1
assert List.first(results).author_first_name == "John"
end

test "aggregate with parent() ref in relationship filter and sorting on relationship field" do

Check failure on line 2008 in test/aggregate_test.exs

View workflow job for this annotation

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

test aggregate with parent() ref in relationship filter and sorting on relationship field (AshSql.AggregateTest)

Check failure on line 2008 in test/aggregate_test.exs

View workflow job for this annotation

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

test aggregate with parent() ref in relationship filter and sorting on relationship field (AshSql.AggregateTest)

Check failure on line 2008 in test/aggregate_test.exs

View workflow job for this annotation

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

test aggregate with parent() ref in relationship filter and sorting on relationship field (AshSql.AggregateTest)
chat_1 =
Chat
|> Ash.Changeset.for_create(:create, %{name: "Test Chat"})
Expand Down
Loading