You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Database Adapter and Versions (postgrex, myxql, etc)
{:exqlite, "0.29.0"} {:ecto_sqlite3, "0.18.1"}
Current behavior
Create a two tables,
create table(:venue) do
end
create table(:event) do
add :venue_id, references(
:venue
on_delete: :restrict
)
end
Try and delete a venue:
Venue |> Ecto.Changeset.change() |> Ecto.Changeset.no_assoc_constraint(:event) |> Repo.delete()
I get a runtime error:
#PID<0.750.0> running Phoenix.Endpoint.SyncCodeReloadPlug (connection #PID<0.749.0>, stream id 1) terminated
Server: 127.0.0.1:4000 (http)
Request: POST /api/graphql
** (exit) an exception was raised:
** (Ecto.ConstraintError) constraint error when attempting to delete struct:
* nil (foreign_key_constraint)
If you would like to stop this constraint violation from raising an
exception and instead add it as an error to your changeset, please
call `foreign_key_constraint/3` on your changeset with the constraint
`:name` as an option.
The changeset defined the following constraints:
* "event_venue_id_fkey" (foreign_key_constraint)
Expected behavior
The error should go into the changeset.
There doesn't appear to be a way to match against "* nil (foreign_key_constraint)" as if I add the opt name: nil, it will use the default generated fk name.
The text was updated successfully, but these errors were encountered:
This is due to a limitation in exqlite/ecto_sqlite3. It's tracked here: elixir-sqlite/ecto_sqlite3#124 and someone commented a workaround that maybe works for you.
I believe this is mostly all in sqlite's realm. I'll need to play with the error returns and figure out if there is a way to make this play nicely with the other adapters. I don't have the link, but on sqlite's forum there were a few places the FK error formatting should be changed but upstream won't because it's been formatted the way it has for years.
Elixir version
1.18.1
Database and Version
{:exqlite, "0.29.0"} {:ecto_sqlite3, "0.18.1"}
Ecto Versions
3.12.1
Database Adapter and Versions (postgrex, myxql, etc)
{:exqlite, "0.29.0"} {:ecto_sqlite3, "0.18.1"}
Current behavior
Create a two tables,
create table(:venue) do
end
create table(:event) do
add :venue_id, references(
:venue
on_delete: :restrict
)
end
Try and delete a venue:
Venue |> Ecto.Changeset.change() |> Ecto.Changeset.no_assoc_constraint(:event) |> Repo.delete()
I get a runtime error:
Expected behavior
The error should go into the changeset.
There doesn't appear to be a way to match against "* nil (foreign_key_constraint)" as if I add the opt name: nil, it will use the default generated fk name.
The text was updated successfully, but these errors were encountered: