You need the other form of update_or_insert:.  This is covered in the 
manual.  I always encourage people to Read The Fine Manual (RTFM) to gain a 
good understanding what's going on.

 
db.person.update_or_insert(db.person.name=='John',
 name='John',birthplace='Chicago')

or

db.foo.update_or_insert(db.foo.user_id==1, haz='c', user_id=1)


On Tuesday, July 31, 2012 11:10:36 AM UTC-4, Alec Taylor wrote:
>
> I want only one value stored per unique user, but using the 
> `update_or_insert()` function is storing multiple values:
>
> db.define_table(
>     'foo',
>     Field('haz', notnull=True, unique=True, requires=IS_IN_SET(['a', 'b', 
> 'c'])),
>     Field('user_id', db.auth_user, unique=True))
>
> db.foo.update_or_insert(haz='a', user_id=1)
> db.foo.update_or_insert(haz='b', user_id=1)
> db.foo.update_or_insert(haz='c', user_id=1)
>
>
> It should only have one record at the end of this, with haz='c' and 
> user_id=1. Instead, it provides 3 records.
>
> How do I get this to work properly?
>
> Thanks for all suggestions,
>
> Alec Taylor
>

-- 



Reply via email to