abueloshika
As I’ve mentioned before I’m currently working on a project that has some gnarly deprecation issues. Being new to Elixir (and development in general) it is proving to be a great learning opportunity but I am very stuck on something.
I have a model like:
schema "person" do
field :date_of_birth, Ecto.Date
field :appointment_time, Ecto.Time
timestamps()
@required_fields ~w(appointment_time)
@optional_fields ~w(date_of_birth)
def changeset(model, params \\ :empty) do
model
|> cast(params, @required_fields, @optional_fields)
end
date_of_birth goes to a date column in the DB and appointment_time to a time_without_timezone. appointment_time’s associated param is a string formatted like “00:00:00”.
I am utterly confused about how to replace these types properly after their deprecations. My current implementation as per my understanding of the docs:
field :date_of_birth, :date
field :appointment_time, :utc_datetime
This is clearly incorrect because the appointment_time fails the cast type validation. I have many examples of this particular requirement throughout the project so I’d really like to understand the correct methodology at play.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security











Showing Posts 1 to 1- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
abueloshika
Sometimes typing this stuff out sharpens your mind.
My problem was that I should have been using
not
utc_datetimeMove along people, nothing to see here. Guy definitely make a post about something he was struggling with for an hour then fixed 30 seconds after posting