sqlite_ecto2 icon indicating copy to clipboard operation
sqlite_ecto2 copied to clipboard

unique_constraint not working

Open jfcalvo opened this issue 6 years ago • 4 comments

As pointed out on README unique_constraint doesn't work as expected (modifying changeset errors) and instead raising an exception.

There are any plans to implement or improve this or it's totally impossible to give support for this validation because SQLite special characteristics?

jfcalvo avatar Oct 10 '17 10:10 jfcalvo

SQLite does not tell you which constraint has been violated, so it's not possible to properly complete the Ecto error response. This is not a great answer, but I'm at a loss for how to improve on it. Suggestions?

scouten avatar Oct 14 '17 18:10 scouten

I don't have the necessary knowledge about SQLite to think in a correct solution sorry.

But a possible workaround could be to use unsafe_validate_unique in your changesets so you have at least a previous (and sadly unsafe) validation.

jfcalvo avatar Oct 18 '17 18:10 jfcalvo

The follow is what I get from running ecto integration. I think the error message does tell which constraint has been violated.

 ** (Sqlite.DbConnection.Error) UNIQUE constraint failed: posts_users_composite_pk.post_id, posts_users_composite_pk.user_id

roylez avatar May 10 '18 22:05 roylez

As noted in the recently-updated README, I am no longer able to actively maintain this project due to some other life circumstances.

I'll review a patch if one comes or transfer ownership to a new maintainer if somebody signals an interest in taking over.

scouten avatar Jun 17 '18 16:06 scouten