Sakthibalan

Sakthibalan

Updating particular column arise Postgres Error: :timestamp IS NULL THEN ash_raise_error

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"”}

Most Liked

Sakthibalan

Sakthibalan

@kamaroly Sorry, I deleted InstallAshFunctionsExtension file, after I restored this file. Everything is working well.

Thank you so much!

Where Next?

Popular in Questions Top

_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
dotdotdotPaul
Okay, I’m having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I’m sure I’...
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 43487 311
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
Lily
In templates/appointment/index.html.eex: &lt;%= for appointment &lt;- @appointments do %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= appoi...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement