Thanks for the reply. But db.executesql('create unique index idx_owner on
bodypart(owner)') returned the below error, and still didn't solve the
problem.
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/martin/Documents/web2py2/gluon/dal.py", line 7234, in
executesql
adapter.execute(query)
File "/home/martin/Documents/web2py2/gluon/dal.py", line 1659, in execute
return self.log_execute(*a, **b)
File "/home/martin/Documents/web2py2/gluon/dal.py", line 1653, in
log_execute
ret = self.cursor.execute(*a, **b)
IntegrityError: indexed columns are not unique
On Tuesday, September 11, 2012 5:17:54 PM UTC+2, villas wrote:
>
> Add this line as a test:
>
> db.executesql('create unique index idx_owner on bodypart(owner)')
>
> to your code like this:
>
> db = DAL('sqlite://storage.db')
> person = db.define_table('person', Field('name'))
> bodypart = db.define_table('bodypart', Field('name'), Field('owner',
> 'reference
> person', unique=True))
> db.executesql('create unique index idx_owner on bodypart(owner)')
> pid = person.insert(name='Sid')
> bpid = bodypart.insert(name='arms', owner= pid)
> bodypart(bpid).owner
> bpid = bodypart.insert(name='mouth', owner= pid)
> bodypart(bpid).owner
>
>
>
--