test: replicate error when building json object and using inline aggregate (#350)

This commit is contained in:
Robert Timis 2024-07-16 21:39:04 +02:00 committed by GitHub
parent a121ba177f
commit 1e637f9205
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 25 additions and 0 deletions

View file

@ -86,6 +86,23 @@ defmodule AshPostgres.Test.ComplexCalculationsTest do
assert certification.count_of_skills_ever_demonstrated == 1
end
test "calculation of inline aggregate" do
skill =
AshPostgres.Test.ComplexCalculations.Skill
|> Ash.Changeset.new()
|> Ash.create!()
AshPostgres.Test.ComplexCalculations.Documentation
|> Ash.Changeset.for_create(:create, %{status: :demonstrated})
|> Ash.Changeset.manage_relationship(:skill, skill, type: :append)
|> Ash.create!()
skill = Ash.load!(skill, [:documentations_custom])
assert %{one: "One", documentations: [%{two: "Two", status: :demonstrated}]} =
skill.documentations_custom
end
test "channel: first_member and second member" do
channel =
AshPostgres.Test.ComplexCalculations.Channel

View file

@ -29,6 +29,8 @@ defmodule AshPostgres.Test.ComplexCalculations.Documentation do
end
calculations do
calculate(:custom_map, :map, expr(%{status: status, two: "Two"}))
calculate(
:timestamp,
:utc_datetime_usec,

View file

@ -39,6 +39,12 @@ defmodule AshPostgres.Test.ComplexCalculations.Skill do
)
end
calculate(
:documentations_custom,
:map,
expr(%{one: "One", documentations: list(documentations, field: :custom_map)})
)
calculate :count_ever_demonstrated, :integer do
calculation(
expr(