mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-20 13:33:50 +12:00
4d2d29d976
feat: support configuring polymorphic references feat: support `distinct` Ash queries
33 lines
700 B
Elixir
33 lines
700 B
Elixir
defmodule AshPostgres.DistinctTest do
|
|
@moduledoc false
|
|
use AshPostgres.RepoCase, async: false
|
|
alias AshPostgres.Test.{Api, Post}
|
|
|
|
require Ash.Query
|
|
|
|
test "records returned are distinct on the provided field" do
|
|
Post
|
|
|> Ash.Changeset.new(%{title: "title"})
|
|
|> Api.create!()
|
|
|
|
Post
|
|
|> Ash.Changeset.new(%{title: "title"})
|
|
|> Api.create!()
|
|
|
|
Post
|
|
|> Ash.Changeset.new(%{title: "foo"})
|
|
|> Api.create!()
|
|
|
|
Post
|
|
|> Ash.Changeset.new(%{title: "foo"})
|
|
|> Api.create!()
|
|
|
|
results =
|
|
Post
|
|
|> Ash.Query.distinct(:title)
|
|
|> Ash.Query.sort(:title)
|
|
|> Api.read!()
|
|
|
|
assert [%{title: "foo"}, %{title: "title"}] = results
|
|
end
|
|
end
|