ash_postgres/test/type_test.exs
Zach Daniel 37cc01957d
improvement!: 3.0 (#227)
* WIP

* chore: fix mix.lock merge issues

* improvement: upgrade to 3.0

* chore: remove `repo.to_tenant`

* chore: continue removal of unnecessary helper

* chore: use `Ash.ToTenant`
2024-03-27 16:52:28 -04:00

38 lines
1,012 B
Elixir

defmodule AshPostgres.Test.TypeTest do
use AshPostgres.RepoCase, async: false
alias AshPostgres.Test.Post
require Ash.Query
test "complex custom types can be used" do
post =
Post
|> Ash.Changeset.for_create(:create, %{title: "title", point: {1.0, 2.0, 3.0}})
|> Ash.create!()
assert post.point == {1.0, 2.0, 3.0}
end
test "complex custom types can be accessed with fragments" do
Post
|> Ash.Changeset.for_create(:create, %{title: "title", point: {1.0, 2.0, 3.0}})
|> Ash.create!()
Post
|> Ash.Changeset.for_create(:create, %{title: "title", point: {2.0, 1.0, 3.0}})
|> Ash.create!()
assert [%{point: {2.0, 1.0, 3.0}}] =
Post
|> Ash.Query.filter(fragment("(?)[1] > (?)[2]", point, point))
|> Ash.read!()
end
test "uuids can be used as strings in fragments" do
uuid = Ash.UUID.generate()
Post
|> Ash.Query.filter(fragment("? = ?", id, type(^uuid, :uuid)))
|> Ash.read!()
end
end