improvement: add date support (#68)

This commit is contained in:
Zach Daniel 2020-06-12 22:39:20 -04:00 committed by GitHub
parent 0092af6a94
commit 5f2019027d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -23,6 +23,7 @@ defmodule Ash.Type do
boolean: [ecto_type: :boolean, filters: [:eq, :not_eq], sortable?: true], boolean: [ecto_type: :boolean, filters: [:eq, :not_eq], sortable?: true],
int: [ecto_type: :integer, filters: [:eq, :in, :not_eq, :not_in], sortable?: true], int: [ecto_type: :integer, filters: [:eq, :in, :not_eq, :not_in], sortable?: true],
uuid: [ecto_type: :binary_id, filters: [:eq, :in, :not_eq, :not_in], sortable?: true], uuid: [ecto_type: :binary_id, filters: [:eq, :in, :not_eq, :not_in], sortable?: true],
date: [ecto_type: :date, filters: [:eq, :in, :not_eq, :not_in], sortable?: true],
utc_datetime: [ utc_datetime: [
ecto_type: :utc_datetime, ecto_type: :utc_datetime,
filters: [:eq, :in, :not_eq, :not_in], filters: [:eq, :in, :not_eq, :not_in],

View file

@ -16,6 +16,7 @@ defmodule Ash.Test.Actions.CreateTest do
attributes do attributes do
attribute :id, :uuid, primary_key?: true, default: &Ecto.UUID.generate/0 attribute :id, :uuid, primary_key?: true, default: &Ecto.UUID.generate/0
attribute :bio, :string attribute :bio, :string
attribute :date, :date
end end
relationships do relationships do
@ -113,7 +114,9 @@ defmodule Ash.Test.Actions.CreateTest do
describe "simple creates" do describe "simple creates" do
test "allows creating a record with valid attributes" do test "allows creating a record with valid attributes" do
assert %Post{title: "foo", contents: "bar"} = assert %Post{title: "foo", contents: "bar"} =
Api.create!(Post, attributes: %{title: "foo", contents: "bar"}) Api.create!(Post,
attributes: %{title: "foo", contents: "bar", date: Date.utc_today()}
)
end end
test "constant default values are set properly" do test "constant default values are set properly" do