After more debugging this morning, and I was able to answer my own question. I believe this is a bug in the code, but I'll let Doug chime in on it's status as a bug or just a weird (wrong?) way of doing things.

My code to call the delete method on the Record object looked like this:
<cfset rf.createRecord("childlit").delete(childlitid=childlitid)>

This successfully deleted the childlit Record keyed on the passed childlitid. This also did _call_ the beforeDelete() function on my childlit Record object, but here is where the bug came in--the record object inside the function was blank. Outputting the result of getChildLitId() inside the beforeDelete() function produced a zero and the iterator was empty (no associated records). So this is why it wasn't deleting any of the linked records.

To work around this, I modified my deletion code to be this:
<cfset rec=rf.createRecord("childlit")>
<cfset rec.setChildLitId(childlitid)>
<cfset rec.load()>
<cfset rec.delete()>

Performing the calls the LONG way ;-) produced a fully loaded Reactor object in the beforeDelete() function and the getChildLitGenreIterator().deleteAll() function worked like a charm.

By the way, this is using rev 251 of Reactor, downloaded on May 2.

Mark

Mark Mazelin wrote:

I have 2 tables joined together with a linking table. I can successfully make these calls:

getChildLitGenreIterator().getQuery()
getChildLitGenreIterator().add(childLitGenreId=currGenreId)
getChildLitGenreIterator().delete(childLitGenreId=currGenreId)

Now I'm trying to setup the deletes so that all the associated entries in the link table when the main record is deleted. I have tried setting up a beforeDelete() function in the main table record, like this:

   <cffunction name="BeforeDelete" access="public">
       <!--- before delete, remove any links --->
       <cfset getChildLitGenreIterator().deleteAll()>
   </cffunction>

I added some debug code to confirm that the beforedelete() is actually firing, but this is not working as I expect. The main record gets deleted, but the entries in the link table remain. I have also tried using the link iterator (when would I use that?), getChildLitGenreIterator().deleteAll(), but that doesn't work either.

Any ideas on what I'm doing wrong? Is there a better way to do this?

Thanks,
Mark



-- Reactor for ColdFusion Mailing List -- [email protected]
-- Archives at http://www.mail-archive.com/reactor%40doughughes.net/






-- Reactor for ColdFusion Mailing List -- [email protected]
-- Archives at http://www.mail-archive.com/reactor%40doughughes.net/


Reply via email to