mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-19 13:03:14 +12:00
show error with calc depending on other exists calc
This commit is contained in:
parent
4b6f2baddd
commit
73fbe7fe92
2 changed files with 11 additions and 1 deletions
|
@ -59,6 +59,8 @@ defmodule AshPostgres.CalculationTest do
|
||||||
|> Ash.Query.filter(c_times_p == 6)
|
|> Ash.Query.filter(c_times_p == 6)
|
||||||
|> Ash.read!()
|
|> Ash.read!()
|
||||||
|
|
||||||
|
Logger.configure(level: :debug)
|
||||||
|
|
||||||
assert [] =
|
assert [] =
|
||||||
Post
|
Post
|
||||||
|> Ash.Query.filter(author: [has_posts: true])
|
|> Ash.Query.filter(author: [has_posts: true])
|
||||||
|
@ -131,6 +133,13 @@ defmodule AshPostgres.CalculationTest do
|
||||||
Post
|
Post
|
||||||
|> Ash.Query.load([:has_author, :has_comments])
|
|> Ash.Query.load([:has_author, :has_comments])
|
||||||
|> Ash.read!()
|
|> Ash.read!()
|
||||||
|
|
||||||
|
# building on top of an exists also works
|
||||||
|
author =
|
||||||
|
author |> Ash.load!([:has_posts, :has_no_posts])
|
||||||
|
|
||||||
|
assert author.has_posts
|
||||||
|
refute author.has_no_posts
|
||||||
end
|
end
|
||||||
|
|
||||||
test "calculations can refer to embedded attributes" do
|
test "calculations can refer to embedded attributes" do
|
||||||
|
|
|
@ -130,7 +130,8 @@ defmodule AshPostgres.Test.Author do
|
||||||
argument(:separator, :string, default: " ", constraints: [allow_empty?: true, trim?: false])
|
argument(:separator, :string, default: " ", constraints: [allow_empty?: true, trim?: false])
|
||||||
end
|
end
|
||||||
|
|
||||||
calculate(:has_posts, :boolean, expr(exists(posts, true)))
|
calculate(:has_posts, :boolean, expr(exists(posts, true == true)))
|
||||||
|
calculate(:has_no_posts, :boolean, expr(has_posts == false))
|
||||||
end
|
end
|
||||||
|
|
||||||
aggregates do
|
aggregates do
|
||||||
|
|
Loading…
Reference in a new issue