attributes do
attribute :id, :uuid do
writable? false
primary_key? true
default &Ecto.UUID.generate/0
allow_nil? false
public? true
end
attribute :first_name, :string do
allow_nil? false
public? true
end
attribute :last_name, :string do
allow_nil? false
public? true
end
attribute :class, :string, public?: true
attribute :section, :string, public?: true
attribute :dob, :date, public?: true
attribute :roll_number, :string, public?: true
create_timestamp :inserted_at
update_timestamp :updated_at
end
student = Ash.get!(MyApp.Students.Student, "806b5689-faaf-4f79-a773-c2817826568e")
#MyApp.Students.Student<
__meta__: #Ecto.Schema.Metadata<:loaded, "students">,
id: "806b5689-faaf-4f79-a773-c2817826568e",
first_name: "xxxx",
last_name: "yyyyy",
class: "1 std",
section: "A",
roll_number: "100",
inserted_at: ~U[2024-05-16 05:38:10.074562Z],
updated_at: ~U[2024-05-16 05:38:10.074562Z],
aggregates: %{},
calculations: %{},
...
>
student |> Ash.Changeset.for_update(:update, %{section: "B"}) |> Ash.update!()
↳ AshPostgres.DataLayer.update_query/4, at: lib/data_layer.ex:1289
** (Ash.Error.Unknown) Unknown Error
- %Postgrex.Error{message: nil, postgres: %{code: :undefined_function, line: “636”, message: “function ash_raise_error(jsonb, timestamp without time zone) does not exist”, position: “93”, file: “parse_func.c”, unknown: “ERROR”, severity: “ERROR”, hint: “No function matches the given name and argument types. You might need to add explicit type casts.”, pg_code: “42883”, routine: “ParseFuncOrColumn”}, connection_id: 23725, query: “UPDATE "students" AS s0 SET "updated_at" = (CASE WHEN $1::timestamp::timestamp IS NULL THEN ash_raise_error($2::jsonb, s0."updated_at"::timestamp) ELSE $3::timestamp::timestamp END), "section" = $4::text WHERE (s0."id"::uuid = $5::uuid) RETURNING s0."id", s0."first_name", s0."last_name", s0."class", s0."section", s0."dob", s0."father_name", s0."mother_name", s0."roll_number", s0."password", s0."inserted_at", s0."updated_at"”}