galbangi
[error] ** (Ecto.NoPrimaryKeyValueError) struct while updating. insert working fine
i am trying to update record. its giving me error. on insert its working fine.
[error] ** (Ecto.NoPrimaryKeyValueError) struct %ShopRestApis.Schema.CustomerSchema{__meta__: #Ecto.Schema.Metadata<:built, "customer">, id: nil, first_name: nil, last_name: nil, address: nil, landmark: nil, city: nil, state: nil, postcode: nil, type: nil, status: nil, mobile: nil, phone: nil, email: nil, company_name: nil, tax_code: nil, jobs: nil, inserted_at: nil, updated_at: nil} is missing primary key value
(ecto 3.12.2) lib/ecto/repo/schema.ex:1078: anonymous fn/3 in Ecto.Repo.Schema.add_pk_filter!/2
but i have id in changes
[(shop_rest_apis 0.1.0) lib/shop_rest_apis/context/customer_context.ex:67: ShopRestApis.Context.CustomerContext.update/2]
value #=> #Ecto.Changeset<
action: nil,
changes: %{
id: "27efc595-dba9-4d9a-8a16-a4fd0d733c17",
status: "Active",
type: "Private",
mobile: "+39,350577777",
first_name: "test"
},
errors: [],
data: #ShopRestApis.Schema.CustomerSchema<>,
valid?: true,
...
>
my update function
def update(%CustomerSchema{} = data, attrs) do
data
|> CustomerSchema.changeset(attrs)
|> Repo.update()
end
controller
def update(conn, params) do
customer =
ContextAliasController.get!(params["id"])
with {:ok, %SchemaAliasController{} = customer} <-
ContextAliasController.update(
customer,
params
) do
render(conn, :show, customer: customer)
end
end
on schema i have uuid as primary key
@primary_key {:id, :binary_id, autogenerate: false}
@foreign_key_type :binary_id
Marked As Solved
al2o3cr
Last Post!
galbangi
Popular in Questions
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
If I have a post route which an argument:
post /my_post_route/:my_param1, MyController.my_post_handler
How would get the post params ...
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
Credo is smart enough to check for (something like) this:
assert length(the_list) == 0
with this response:
Checking if an enum is empt...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
15:22:35.803 [error] gen_event {lager_file_backend...
New
Other popular topics
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
New
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
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










