Closed Artexis10 closed 4 weeks ago
Can you please provide the full code?
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.
Are you able to replicate the issue?
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?
@Artexis10 Were you able to produce a simpler example that can reproduce this? I played around with it myself and checked the code carefully and wasn't able to find a way to reproduce.
Closing this. Glad to reopen if there is a way to reproduce it.
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.