krainboltgreene
I am attempting to create two records at once in my database: An adventure and many acts, where an adventure has many acts.
For some reason when I create an adventure it seemingly inserts one of the acts and then tries to insert a second adventure?
INSERT INTO "adventures" ("agent_person_id","contract_person_id","plot","type","world_id","inserted_at","updated_at","id") VALUES ($1,$2,$3,$4,$5,$6,$7,$8) [<<68, 147, 149, 173, 180, 173, 75, 0, 180, 244, 90, 191, 153, 186, 178, 215>>, <<186, 63, 34, 237, 155, 136, 68, 155, 170, 252, 3, 181, 208, 228, 239, 54>>, "placeholder", "placeholder", <<130, 112, 39, 250, 101, 217, 66, 162, 174, 235, 144, 23, 17, 78, 226, 167>>, ~N[2022-01-16 04:41:54], ~N[2022-01-16 04:41:54], <<233, 125, 1, 196, 52, 201, 79, 78, 140, 135, 179, 22, 224, 137, 5, 213>>]
[debug] QUERY OK db=1.2ms
INSERT INTO "acts" ("adventure_id","world_id","inserted_at","updated_at","id") VALUES ($1,$2,$3,$4,$5) [<<233, 125, 1, 196, 52, 201, 79, 78, 140, 135, 179, 22, 224, 137, 5, 213>>, <<130, 112, 39, 250, 101, 217, 66, 162, 174, 235, 144, 23, 17, 78, 226, 167>>, ~N[2022-01-16 04:41:54], ~N[2022-01-16 04:41:54], <<151, 150, 215, 195, 161, 77, 74, 157, 135, 136, 163, 202, 35, 132, 75, 203>>]
[debug] QUERY ERROR db=7.9ms
INSERT INTO "adventures" ("inserted_at","updated_at","id") VALUES ($1,$2,$3) [~N[2022-01-16 04:41:54], ~N[2022-01-16 04:41:54], <<218, 158, 22, 55, 104, 91, 64, 125, 143, 216, 110, 121, 85, 170, 53, 210>>]
[debug] QUERY OK db=0.6ms
rollback []
As you can see the adventure I tried to create successfully inserted into the database. Then the first of the acts gets inserted, then finally an error as an invalid adventure gets inserted.
I have checked all the locations where I call Repo.insert() and have accounted for all of them. The stacktrace I get for this error is a bunch of macro gibberish:
** (Postgrex.Error) ERROR 23502 (not_null_violation) null value in column "plot" of relation "adventures" violates not-null constraint
table: adventures
column: plot
Failing row contains (da9e1637-685b-407d-8fd8-6e7955aa35d2, null, null, null, null, null, 2022-01-16 04:41:54, 2022-01-16 04:41:54).
(ecto_sql 3.7.1) lib/ecto/adapters/sql.ex:760: Ecto.Adapters.SQL.raise_sql_call_error/1
(ecto 3.7.1) lib/ecto/repo/schema.ex:744: Ecto.Repo.Schema.apply/4
(ecto 3.7.1) lib/ecto/repo/schema.ex:367: anonymous fn/15 in Ecto.Repo.Schema.do_insert/4
(ecto 3.7.1) lib/ecto/association.ex:1083: Ecto.Association.BelongsTo.on_repo_change/5
(ecto 3.7.1) lib/ecto/association.ex:554: Ecto.Association.on_repo_change/7
(elixir 1.13.0) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
(ecto 3.7.1) lib/ecto/association.ex:532: Ecto.Association.on_repo_change/4
(ecto 3.7.1) lib/ecto/repo/schema.ex:873: Ecto.Repo.Schema.process_parents/5
(ecto 3.7.1) lib/ecto/repo/schema.ex:347: anonymous fn/15 in Ecto.Repo.Schema.do_insert/4
(ecto 3.7.1) lib/ecto/association.ex:1083: Ecto.Association.BelongsTo.on_repo_change/5
(ecto 3.7.1) lib/ecto/association.ex:554: Ecto.Association.on_repo_change/7
(elixir 1.13.0) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
(ecto 3.7.1) lib/ecto/association.ex:532: Ecto.Association.on_repo_change/4
(ecto 3.7.1) lib/ecto/repo/schema.ex:873: Ecto.Repo.Schema.process_parents/5
(ecto 3.7.1) lib/ecto/repo/schema.ex:347: anonymous fn/15 in Ecto.Repo.Schema.do_insert/4
(ecto 3.7.1) lib/ecto/association.ex:814: Ecto.Association.Has.on_repo_change/5
(ecto 3.7.1) lib/ecto/association.ex:572: anonymous fn/8 in Ecto.Association.on_repo_change/7
(elixir 1.13.0) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
(ecto 3.7.1) lib/ecto/association.ex:568: Ecto.Association.on_repo_change/7
(elixir 1.13.0) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
I can provide as much detail as needed
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted”
Version...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
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 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
dimitarvp
Post the relevant Elixir code, please?
slouchpie
Are you using
put_assocorcast_assocanywhere? My hunch is in theActschema you are using one of these.krainboltgreene
I am in fact using cast_assoc in adventures and act. Adventures cast_assoc Acts and Acts cast_assoc a third relationship
slouchpie
Post the relevant Elixir code, please?