Skip to content

Commit a53853e

Browse files
committed
chore: Add test for intersects/2 with mismatched array types
1 parent bec1bae commit a53853e

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

test/filter_test.exs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,4 +1323,26 @@ defmodule AshPostgres.FilterTest do
13231323
assert id2 == post_false.id
13241324
end
13251325
end
1326+
1327+
describe "intersects/2 with mismatched array types" do
1328+
test "uuid array intersects with text array" do
1329+
post =
1330+
Post
1331+
|> Ash.Changeset.for_create(:create, %{title: "post with comments"})
1332+
|> Ash.create!()
1333+
1334+
comment =
1335+
Comment
1336+
|> Ash.Changeset.for_create(:create, %{title: "comment1"})
1337+
|> Ash.Changeset.manage_relationship(:post, post, type: :append_and_remove)
1338+
|> Ash.create!()
1339+
1340+
comment_id_as_string = to_string(comment.id)
1341+
1342+
assert [%Post{}] =
1343+
Post
1344+
|> Ash.Query.filter(intersects(comment_ids, [^comment_id_as_string]))
1345+
|> Ash.read!()
1346+
end
1347+
end
13261348
end

test/support/resources/post.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,8 @@ defmodule AshPostgres.Test.Post do
13351335
sort(title: :asc_nils_last)
13361336
end
13371337

1338+
list(:comment_ids, :comments, :id)
1339+
13381340
sum :total_edited_time, :comments, :edited_duration do
13391341
filter(expr(version == :edited))
13401342
public?(true)

0 commit comments

Comments
 (0)