Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation before delete? Is it necessary #85

Open
bmfay opened this issue Jun 2, 2020 · 0 comments
Open

Validation before delete? Is it necessary #85

bmfay opened this issue Jun 2, 2020 · 0 comments

Comments

@bmfay
Copy link
Contributor

bmfay commented Jun 2, 2020

After updating a pretty old project to Ecto 3.4 and Elixir 1.7, I found I had a whole bunch of failing tests anywhere where I was not overriding ja_resource's handle_delete. The reason was this line.

|> __MODULE__.model.changeset(%{})

This was resulting in my controllers returning 422's where 204's were expected due to the record not passing validation (which is part of the changeset function in most cases). I haven't figured out why this changed in my upgrade, but regardless, I wanted to understand why this line is there.

If you are going to delete a record, what is the use in building a changeset from it first? And if it gets marked invalid in that process (for example if the record were created before you added some stricter validations later on), why should that prevent a delete?

I'm going to fork and remove this for now, but I am probably missing something so I would love to discuss if anyone has thoughts on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant