mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-19 21:13:19 +12:00
37cc01957d
* 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`
38 lines
1,012 B
Elixir
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
|