I just saw this:
Field(name, 'string', length=None, default=None,
required=False, requires='<default>',
ondelete='CASCADE', notnull=False, unique=False,
uploadfield=True, widget=None, label=None, comment=None,
writable=True, readable=True, update=None, authorize=None,
autodelete=False, represent=None, compute=None,
uploadfolder=None,
uploadseparate=None,uploadfs=None)
ondelete translates into the "ON DELETE" SQL statement. By
default it is set to "CASCADE". This tells the database that when it
deletes a record, it should also delete all records that refer to it. To
disable this feature, set ondelete to "NO ACTION" or "SET NULL".
So I guess that means it cascades by default.
A separate question… if record versioning is turned on, and SQLFORM
deletable=True, the following error is produced, may I know what I am doing
incorrectly?
Traceback (most recent call last):
File "/.../web2py/source/gluon/restricted.py", line 221, in restricted
exec ccode in environment
File "/.../web2py/source/applications/.../controllers/default.py", line 247,
in <module>
File "/.../web2py/source/gluon/globals.py", line 389, in <lambda>
self._caller = lambda f: f()
File "/.../web2py/source/gluon/tools.py", line 3465, in f
return action(*a, **b)
File "/.../web2py/source/applications/.../controllers/default.py", line 217,
in edit_this
if
form.process(onvalidation=sqlform_validate,onsuccess=auth.archive).accepted:
File "/.../web2py/source/gluon/html.py", line 2289, in process
self.validate(**kwargs)
File "/.../web2py/source/gluon/html.py", line 2233, in validate
onsuccess(self)
File "/.../web2py/source/gluon/tools.py", line 3849, in archive
id = archive_table.insert(**new_record)
File "/.../web2py/source/gluon/dal.py", line 9252, in insert
ret = self._db._adapter.insert(self, self._listify(fields))
File "/.../web2py/source/gluon/dal.py", line 1362, in insert
raise e
IntegrityError: foreign key constraint failed
Is it trying to cascade delete but failed?
On Friday, July 4, 2014 4:00:12 PM UTC+8, lyn2py wrote:
>
> Hi guys,
>
> Just a simple question, does the SQLFORM deletable=True trigger a cascade
> delete?
>
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.