Yes I did. Dal seems to try to put 0 in database but MySQL rejects the value, since there is no row with index 0. I think the proper way to indicate None in MySQL would be NULL.
On Jun 1, 7:14 pm, Massimo Di Pierro <[email protected]> wrote: > Did you try: > db.define_table("tags", > Field("name","string"), > Field("parent", "reference tags",default=None), > format="%(name)s") > > On Jun 1, 9:30 am, Oskari <[email protected]> wrote: > > > > > > > > > Hi, > > > I'm reporting a possible bug with trunk version of dal.py. I'm having > > the traceback: > > > Traceback (most recent call last): > > File "/home/www-data/web2py/gluon/restricted.py", line 184, in > > restricted > > exec ccode in environment > > File "/home/www-data/web2py/applications/backend/controllers/ > > appadmin.py", line 411, in <module> > > File "/home/www-data/web2py/gluon/globals.py", line 135, in <lambda> > > self._caller = lambda f: f() > > File "/home/www-data/web2py/applications/backend/controllers/ > > appadmin.py", line 127, in insert > > if form.accepts(request.vars, session): > > File "/home/www-data/web2py/gluon/sqlhtml.py", line 1205, in accepts > > self.vars.id = self.table.insert(**fields) > > File "/home/www-data/web2py/gluon/dal.py", line 4634, in insert > > return self._db._adapter.insert(self,self._listify(fields)) > > File "/home/www-data/web2py/gluon/dal.py", line 814, in insert > > raise e > > IntegrityError: (1452, u'Cannot add or update a child row: a foreign > > key constraint fails (`tuubiodb`.`tags`, CONSTRAINT `tags_ibfk_1` > > FOREIGN KEY (`parent`) REFERENCES `tags` (`id`) ON DELETE CASCADE)') > > > with table definition > > > db.define_table("tags", > > Field("name","string"), > > Field("parent", "reference tags",required=False), > > format="%(name)s") > > > Web2py tries to insert parent with value 0, while mySQL only accepts > > "null" as a reference to non-existing table.

