> this too works :
>
> db.define_table('fruit_couple',
>                 Field('fru','list:reference fruits', required=True, 
> unique=True))
>
> def ins():
>     try:
>         db.fruit_couple.insert(fru=[10,15])
>         result="inserted"
>     except:
>         result="rejected"
>     return locals()
>
> dont know if it's a good thing or not to let the database throw exceptions 
> ?
>

That's fine, but keep in mind the above will let you insert both fru=[10, 
15] and fru=[15, 10] without throwing an exception, so you would always 
want to sort the values in the list to ensure identical sets will always 
have the same order.

Also, so far we have only discussed inserts, but you must also consider 
updates -- make sure an update doesn't result in one record becoming a 
duplicate of another record. This is trickier if you will potentially be 
updating only a single reference value at a time.

Anthony

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to