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

Support for on-delete='CASCADE' with soft deletes #505

Closed
mbadolato opened this issue Nov 9, 2012 · 31 comments
Closed

Support for on-delete='CASCADE' with soft deletes #505

mbadolato opened this issue Nov 9, 2012 · 31 comments

Comments

@mbadolato
Copy link

When using soft deletes, and entity object is not actually being deleted, thus no cascades trigger down to associated objects.

My original email with @l3pp4rd and @comfortablynumb:

I'm using the soft delete feature, and its working well. In the relationship defined below, I have soft delete set up on both the Event entity (where this association is defined), as well as the associated entity, EventMetaDataValue.

I'd like to include on-delete="CASCADE" so that the associated EventMetadataValue's deletedAt timestamp also gets updated, however this doesn't seem to trigger. Presumably this is because I'm not actually deleting the Event entity, since I'm using soft delete.

My question is, is there a way to have that behavior take place (i.e., cascade the soft-delete down to the associated table)? Scouring the net didn't lead me to anything useful, and your docs don't reference a situation like that. I was hoping there was a syntactical way to carry out this operation, and that I won't have to write a listener to take care of it.

    <entity name="Cms\CoreBundle\Entity\Event" table="event">
         ...
        <many-to-many field="eventMetadataValues" target-entity="EventMetadataValue">
            <join-table name="event_metadata">
                <join-columns>
                    <join-column name="event_id" referenced-column-name="id" />
                </join-columns>
                <inverse-join-columns>
                    <join-column name="event_metadata_value_id" referenced-column-name="id" />
                </inverse-join-columns>
            </join-table>
        </many-to-many>
         ...
    </entity>

And Gustavo's response:

You're right, since entities which are not explicitly removed from the entity manager don't trigger any events, they are not handled by softdeleteable. One way would be to use cascade delete. But, of course, this avoids the perfomance boost of using normal db cascade delete.

We could detect, however, an entity which is being deleted and, if it has a configuration in its join columns with cascade delete, we could softdelete its children.

@alex88
Copy link

alex88 commented Feb 10, 2013

+1 for this feature, the actual implementation creates exceptions with the JMSSerializer which throws "Entity was not found" exception when trying to load an entity by ID but since it has added the WHERE deletetAt == null it doesn't return anything and gives errors.

@baohx2000
Copy link

+1

1 similar comment
@oscargala
Copy link

+1

@mbadolato
Copy link
Author

@comfortablynumb Were you ever able to determine if this would be possible, and if so, how difficult of an implementation?

@zeroset
Copy link

zeroset commented Apr 18, 2013

+1

@zeroset
Copy link

zeroset commented Apr 22, 2013

Is there something new on soft delete and cascade remove?

@l3pp4rd
Copy link
Contributor

l3pp4rd commented Apr 22, 2013

it may not be hard to implement, but the author of softdeleteable is away.. and there is no news about it, most probably someone will contribute to solve this

@mdavis1982
Copy link

👍

@mamartins
Copy link

I came across this same problem but the other way around:
I have a Sale entity that has a price, a date and a service id.
And I have a service entity that have an id and a name.

I want to be able to delete the service as expected but the sale still appearing in the history, and referencing that same service. Any suggestion on this?

@nurikabe
Copy link

nurikabe commented Aug 1, 2014

+1

5 similar comments
@andrey-bondar
Copy link

+1

@joseandrespg
Copy link

+1

@liverbool
Copy link

👍

@broncha
Copy link

broncha commented Jul 8, 2015

+1

@velanor
Copy link

velanor commented Jul 14, 2015

+1

@respinoza

This comment has been minimized.

@prvijesh
Copy link

subscribe the event 'preSoftDelete'

@rufinus

This comment has been minimized.

@stephanvierkant
Copy link
Collaborator

This would be a great improvement!

Any update or work-around on this?

@Mopster

This comment has been minimized.

3 similar comments
@ricardogama

This comment has been minimized.

@murilolobato

This comment has been minimized.

@tputnoky

This comment has been minimized.

@glen-84
Copy link

glen-84 commented May 19, 2016

@Puty Please use reactions now, instead of +1 comments.

@RubenHarms
Copy link

see https://github.com/E-vence/SoftDeleteableListenerExtensionBundle

@nurikabe
Copy link

nurikabe commented Oct 5, 2016

@RubenHarms GitHub needs a "weeps for joy" reaction icon. Thank you!

@doctrine-extensions doctrine-extensions deleted a comment from glnemeth Jan 23, 2018
@doctrine-extensions doctrine-extensions deleted a comment from ghanbari Jan 23, 2018
@doctrine-extensions doctrine-extensions deleted a comment from versh23 Jan 23, 2018
@doctrine-extensions doctrine-extensions deleted a comment from emr Jan 23, 2018
@doctrine-extensions doctrine-extensions deleted a comment from adapik Jan 23, 2018
@doctrine-extensions doctrine-extensions deleted a comment from gpenverne Jan 23, 2018
@stephanvierkant
Copy link
Collaborator

@adapik @gustavodpont @funcphp @glnemeth @ghanbari @versh23 @gpenverne

I've removed your comments. Please use reactions instead of +1 comments.

@jelovac
Copy link

jelovac commented Jul 12, 2021

Hi,

Has any progress been made during the years regarding this missing feature? Is it still an issue in v3?

@AkenRoberts
Copy link
Member

No progress that I'm aware of.

@github-actions
Copy link

github-actions bot commented Jan 8, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Jan 8, 2022
@github-actions github-actions bot closed this as completed Feb 7, 2022
@asdfMaciej
Copy link

Has this issue been solved? The completed tag seems misleading, perhaps it should be reopened?

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

No branches or pull requests