I experienced the same, there seem to be some funny thing going on with 
self referencing. 

On Tuesday, August 23, 2016 at 12:30:40 AM UTC-4, pbreit wrote:
>
> Well, just removing the db.commit() made it work as well except that it 
> doesn't populate the self referencing field.
>
> if db(db.comment).count()<2:
>     populate(db.comment, 30)
>
>
> On Monday, August 22, 2016 at 9:09:45 PM UTC-7, pbreit wrote:
>>
>> I fixed by specifying:
>>
>> if db(db.comment).count()<2:
>>     import random
>>     for i in range(1,20):
>>         populate(db.comment, 1, contents={'parent_comment': i})
>>     db.commit()
>>
>>
>>
>> On Monday, August 22, 2016 at 8:47:48 PM UTC-7, pbreit wrote:
>>>
>>> Trying to populate:
>>>
>>> db.define_table('comment',
>>>     Field('post_id', 'reference post'),
>>>     Field('parent_comment', 'reference comment'),
>>>     Field('body', 'text', requires=IS_NOT_EMPTY()),
>>>     Field('votes', 'integer'),
>>>     auth.signature)
>>>
>>>
>>> with:
>>>
>>> if db(db.comment).count()<2:
>>>     populate(db.comment, 50)
>>>     db.commit()
>>>
>>> but getting "IntegrityError: FOREIGN KEY constraint failed" unless I 
>>> remove 'reference comment'
>>>
>>> Is gluon.contrib.populate able to seed a table with a self reference?
>>>
>>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to