[TYPO3-mvc] Clear repository - was: delete/truncate SQL statements

Jochen Rau jochen.rau at typoplanet.de
Wed Jan 27 15:43:07 CET 2010


Hi.

On 27.01.10 13:12, Karsten Dambekalns wrote:
> Hi.
>
> On 26.01.10 21:47, Martin Kutschker wrote:
>>> I wanted to get rid of my demo data without having to use phpMyAdmin or the Mysql shell. So I tried
>>> to add a removeAll() method to my repositories. But I lost my way in the numerous classes of the
>>> persistence layer.
>
> Well, in FLOW3 we have removeAll(), it basically does findAll() and
> calls remove() for every object.

Implemented in Extbase with r1805 now.

>
>> Maybe the reference to SQL was misleading. May main question/request is to clear/empty a repository.
>> Technically this would boil down to using either DELETE or TRUNCATE statements. But what else needs
>> to be done?
>
> That is the part that makes it complicated. Currently I am adding CRUD
> "hooks" to the persistence, so when removing an object we need to have
> that object and hand it over to whatever method is registered with that
> hook ("signal" in FLOW3, coming from the Qt Signal/Slot mechanism).
>
> That means we really need to handle every object, one by one.
>
> What you need is really a "I know what I am doing, so just truncate all
> that stuff, now, fast" method. The question here is, again, how far can
> that go? If you remove *everything*, it's easy. But what if you want to
> clear one repository? You still need to check for pointers to objects in
> that repository from elsewhere, so a simple truncation could lead to
> severe inconsistencies.
>
> You see, right now I have more questions than solutions. Maybe someone
> has a bunch of answers?

Sebastian and I elaborated on this problem recently. Removing all 
Aggregate Roots from a Repository (and deleting them from the database) 
is easy, but what to do with Posts, Tags, Comments, Administrators, 
attached files? If a Blog is removed all its Posts should also be 
removed, but not the Administrator of the Blog.

For this reason I have implemented a "@cascade remove" annotation (sorry 
Karsten for not filing an issue in FLOW3 ;-)). By default Extbase leave 
the Child objects of an Aggregate untouched unless the property is 
annotated with "@cascade remove".

BTW If there is a "deleted" column specified in the TCA it sets this to 
1 rather than deleting it really from the database. Do you have such a 
flag in the CR of FLOW3? -- Just kidding ,-)

IMO we should also implement a "@cascade nofetch" to be able to fetch 
the related stuff manually in the Repository.

Regards
Jochen


More information about the TYPO3-project-typo3v4mvc mailing list