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

Behavior hook for DELETE #1959

Open
marcoas opened this issue Feb 24, 2023 · 0 comments
Open

Behavior hook for DELETE #1959

marcoas opened this issue Feb 24, 2023 · 0 comments

Comments

@marcoas
Copy link

marcoas commented Feb 24, 2023

(Translated by Google)

Hello

I have already created and loaded for all the tables, a behavior very similar to the example in: timestampable.
There, I override the preInsert and preUpdate methods.
That works very well.

Now I need to be able to control this situation:

  • When doing a DELETE and it fails due to a foreign key constraint, I want to catch the error, and perform a particular action. In my case, perform a "logical delete" (set the "disabled" field of the record to true)

Can this be done with a behavior?

I tried to do it with the postDelete hook, but due to the constraint error, this method does not get executed.

I tried putting a delete function in the behavior, with the intention of overriding that method, but it doesn't seem to work or I didn't do it right.

Can someone tell me how to do 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