All are expected except for the id: 3, in the book, it is supposed to be nil. Because that’s the point of that lesson, where we are trying to “upsert” a data. But instead, it seems like I have “inserted”? the data.
Anyone knows what I’m talking about?
If more info is needed do let me know, thanks.
It’s not possible to insert a entry with name "hello" twice (if your unique_constraint was defined correctly), as the constraint is checked by the database.
Double-check your setup and constraints, also make sure that you drop the database (done automatically with mix ecto.reset) if you are editing migrations, as ecto cannot track modifications to migrations that already ran.
The default value for :on_conflict is :raise. Once we change it to :nothing, no exceptions
are raised and you can see the returned category has a nil id, indicating that
indeed the category was not inserted.
"