yes CASCADE is default.

On Sep 19, 3:57 pm, weheh <[email protected]> wrote:
> Massimo: I agree, it seems like an ondelete='CASCADE' behavior. But
> now I'm confused.
>
> Maybe I don't understand how ondelete='CASCADE' works. In my example,
> the child references the parent. If you delete the parent, the child
> should go away. In actuality, it does. So does the queue because the
> queue refers to the parent. However, since the child doesn't reference
> the queue, why would deleting the queue delete the child?
>
> Regarding the doc, it's not at all clear that ondelete='CASCADE' is
> the default action if not specified. Also, there is nothing in the doc
> that says how to turn of ondelete='CASCADE'. I could not find
> ondelete='NO ACTION'. I have modified the doc accordingly. Please
> review my edits when you get a chance.
>
> On Sep 19, 2:00 pm, mdipierro <[email protected]> wrote:
>
> > I do not understand
>
> > > When I delete the parent, it's child is deleted, which is what I expect.
>
> > how can it be? parent does not link the child
>
> > > When I delete the queue entry, the child is deleted, which is not desired.
>
> > This has nothing to do with autodelete, this has to do with
> > ondelete='cascade'. You want (I think)
>
> > Field('child',db.child,requires=IS_IN_DB(db,'child.id'),ondelete='NO
> > ACTION')
>
> > On Sep 19, 12:48 pm, weheh <[email protected]> wrote:
>
> > > db.define_table('child',
> > >   Field('parent',db.parent,
> > >     requires=IS_NULL_OR(IS_IN_DB(db,'parent.id','%(title)s'))),
> > >   Field('name','upload',length=50,
> > >     autodelete=True,
> > >     uploadfolder=os.path.join(request.folder,'static/data/child'),
> > >     uploadseparate=True,
> > >     )
> > >   )
> > > db.define_table('parent',
> > >   Field('user_id',db.auth_user,
> > >     requires=IS_NULL_OR(IS_IN_DB(db,'auth_user.id'))),
> > >   Field('categ',db.categ,label=T('Category'),default=12,
> > >     requires=IS_IN_DB(db,'categ.id','%(name)s',zero=None)),
> > >   Field('blah1','string',length=50,label=T('Blah')),
> > >   Field('blah2','string',length=50,label=T('Blah')),
> > >   Field('blah3','string',length=50,label=T('Blah')),
> > > etc.
> > > )
> > > db.define_table('queue',
> > >   Field('user_id',db.auth_user,
> > >     requires=IS_NULL_OR(IS_IN_DB(db,'auth_user.id'))),
> > >   Field('parent',db.parent,requires=IS_IN_DB(db,'parent.id')),
> > >   Field('start','datetime'),
> > >   Field('end','datetime'),
> > >   Field('child',db.child,requires=IS_IN_DB(db,'child.id')),
> > >   )
>
> > > When I delete the parent, it's child is deleted, which is what I
> > > expect.
> > > When I delete the queue entry, the child is deleted, which is not
> > > desired.
>
> > > On Sep 19, 1:24 am, mdipierro <[email protected]> wrote:
>
> > > > Can you show us the table in question and the queue table?
>
> > > > On Sep 18, 10:59 pm, weheh <[email protected]> wrote:
>
> > > > > I have a table with an upload field declared with autodelete=True. The
> > > > > upload file is not really uploaded, it's created on the fly. The table
> > > > > id is referenced by a queue, which is polled to determine whether or
> > > > > not the upload file needs to be created. Once created, the queue entry
> > > > > is deleted. This is where the problem is -- deleting the queue entry
> > > > > also deletes the uploaded file. I only want the uploaded file deleted
> > > > > when it's parent record is deleted, not when the queue record is
> > > > > deleted. I've tried a db.mytable.fieldname.autodelete=False just
> > > > > before deleting the queue entry, but this doesn't work. What should I
> > > > > be doing?
>
>

Reply via email to