MySQL, self-reference, and null values

136 views
Skip to first unread message

Loïc

unread,
Feb 1, 2013, 10:20:54 AM2/1/13
to web...@googlegroups.com
Dear All,

I have a 'page' model with a sef-reference:
db.define_table('page',
    Field('parent', 'reference page', readable=False, writable=False),
    Field('title', unique=True, notnull=True)
    //more fields not important here
)

When I insert a new page via appadmin without specifying a 'parent', everything is OK with sqlite

Since I moved my database to mysql, I have an error :

<class '_mysql_exceptions.IntegrityError'> (1452, 'Cannot add or update a child row: a foreign key constraint fails (`dommartin25`.`page`, CONSTRAINT `page_ibfk_1` FOREIGN KEY (`parent`) REFERENCES `page` (`id`) ON DELETE CASCADE)')


How can I allow null values for the 'parent' field?

Thank you

Massimo Di Pierro

unread,
Feb 10, 2013, 6:40:26 PM2/10/13
to web...@googlegroups.com
Any advice about this. I am not sure about the problem. Seems mysql specific.

Massimo Di Pierro

unread,
Feb 10, 2013, 6:40:59 PM2/10/13
to web...@googlegroups.com
Can you please open a ticket so the issue is tracked?


On Friday, 1 February 2013 09:20:54 UTC-6, Loïc wrote:

Loïc

unread,
Feb 18, 2013, 5:28:45 AM2/18/13
to web...@googlegroups.com

Oasis Agano

unread,
Oct 25, 2017, 12:54:08 PM10/25/17
to web2py-users
Has this issue been solved still facing it after 4 years on mysql

Dave S

unread,
Oct 25, 2017, 2:29:49 PM10/25/17
to web2py-users


On Wednesday, October 25, 2017 at 9:54:08 AM UTC-7, Oasis Agano wrote:
Has this issue been solved still facing it after 4 years on mysql


Dunno.  In the current tracking system, I'd expect the imported issue to show up on this page:
<URL: https://github.com/web2py/web2py/issues?page=25&q=is%3Aissue&utf8=%E2%9C%93>
but I don't see it there (disclaimer: quick check) as either still open or closed-in-github.
Clicking the link below redirects to the github #1342, which is unrelated (and from 2016).

/dps


I don't know where the lo

fkn sec

unread,
Sep 17, 2018, 11:58:26 PM9/17/18
to web2py-users
Noticed when doing the migration, you have to both add the group and manually add the user in the database table. That solved my issue.
Reply all
Reply to author
Forward
0 new messages