File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change 1
1
defmodule AshPostgres.FilterTest do
2
- alias AshPostgres.Test.Organization
3
2
use AshPostgres.RepoCase , async: false
4
- alias AshPostgres.Test . { Author , Comment , Post }
3
+
4
+ alias AshPostgres.Test . { Author , Comment , Post , Organization }
5
5
alias AshPostgres.Test.ComplexCalculations . { Channel , ChannelMember }
6
6
7
7
require Ash.Query
8
+ import Ash.Expr
8
9
9
10
describe "with no filter applied" do
10
11
test "with no data" do
@@ -1070,4 +1071,29 @@ defmodule AshPostgres.FilterTest do
1070
1071
)
1071
1072
|> Ash . read! ( )
1072
1073
end
1074
+
1075
+ test "filter with ref" do
1076
+ organization =
1077
+ Organization
1078
+ |> Ash.Changeset . for_create ( :create , % { name: "foo" } )
1079
+ |> Ash . create! ( )
1080
+
1081
+ post =
1082
+ Post
1083
+ |> Ash.Changeset . for_create ( :create , % { organization_id: organization . id } )
1084
+ |> Ash . create! ( )
1085
+
1086
+ comment =
1087
+ Comment
1088
+ |> Ash.Changeset . for_create ( :create , % { title: "not match" } )
1089
+ |> Ash.Changeset . manage_relationship ( :post , post , type: :append_and_remove )
1090
+ |> Ash . create! ( )
1091
+
1092
+ fetched_org =
1093
+ Organization
1094
+ |> Ash.Query . filter ( ^ ref ( :id , [ :posts , :comments ] ) == ^ comment . id )
1095
+ |> Ash . read_one! ( )
1096
+
1097
+ assert fetched_org . id == organization . id
1098
+ end
1073
1099
end
You can’t perform that action at this time.
0 commit comments