mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-20 05:23:18 +12:00
test: replicate error when building json object and using inline aggregate (#350)
This commit is contained in:
parent
a121ba177f
commit
1e637f9205
3 changed files with 25 additions and 0 deletions
|
@ -86,6 +86,23 @@ defmodule AshPostgres.Test.ComplexCalculationsTest do
|
||||||
assert certification.count_of_skills_ever_demonstrated == 1
|
assert certification.count_of_skills_ever_demonstrated == 1
|
||||||
end
|
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
|
test "channel: first_member and second member" do
|
||||||
channel =
|
channel =
|
||||||
AshPostgres.Test.ComplexCalculations.Channel
|
AshPostgres.Test.ComplexCalculations.Channel
|
||||||
|
|
|
@ -29,6 +29,8 @@ defmodule AshPostgres.Test.ComplexCalculations.Documentation do
|
||||||
end
|
end
|
||||||
|
|
||||||
calculations do
|
calculations do
|
||||||
|
calculate(:custom_map, :map, expr(%{status: status, two: "Two"}))
|
||||||
|
|
||||||
calculate(
|
calculate(
|
||||||
:timestamp,
|
:timestamp,
|
||||||
:utc_datetime_usec,
|
:utc_datetime_usec,
|
||||||
|
|
|
@ -39,6 +39,12 @@ defmodule AshPostgres.Test.ComplexCalculations.Skill do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
calculate(
|
||||||
|
:documentations_custom,
|
||||||
|
:map,
|
||||||
|
expr(%{one: "One", documentations: list(documentations, field: :custom_map)})
|
||||||
|
)
|
||||||
|
|
||||||
calculate :count_ever_demonstrated, :integer do
|
calculate :count_ever_demonstrated, :integer do
|
||||||
calculation(
|
calculation(
|
||||||
expr(
|
expr(
|
||||||
|
|
Loading…
Reference in a new issue