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
Following the documentation of check_constraint, this is the error that occurs:
** (Ecto.ConstraintError) constraint error when attempting to insert struct:
* "entity_id_entity_code" (check_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 `check_constraint/3` on your changeset with the constraint
`:name` as an option.
The changeset has not defined any constraint.
The expectation is that the Ecto.ConstraintError is handled and does not raise an exception. Currently, it does not and suggests that to handle this, the check_constraint function needs to be defined on the changeset, which it already is.
The text was updated successfully, but these errors were encountered:
The fact the error message does not list your constraint seems to indicate that the constraint is not effectively stored in the changeset. Maybe you are setting the constraint and then discarding the changeset (or returning another changeset).
I am unable to provide more code as there would be a confidentiality issue. In the code, I am returning the same changeset, so it is unlikely to be that.
You need to do provide us a way to replicate the issue. We have tests for check_constraint that pass so it's not easy for us to know how to replicate your issue.
Can you write some example code that shows the issue, ideally by providing a mix project that reproduces the error?
Elixir version
1.15.6
Database and Version
PostgreSQL 11.12
Ecto Versions
3.10.3
Database Adapter and Versions (postgrex, myxql, etc)
0.17.3
Current behavior
Here is the implementation:
Migration:
Schema:
check_constraint(:entity_id, name: :entity_id_entity_code)
Following the documentation of
check_constraint
, this is the error that occurs:Stacktrace:
Expected behavior
The expectation is that the Ecto.ConstraintError is handled and does not raise an exception. Currently, it does not and suggests that to handle this, the
check_constraint
function needs to be defined on the changeset, which it already is.The text was updated successfully, but these errors were encountered: