multiple solutions have been posted in this group, but it depends if you
need a validation that works for forms (in which case a requires with a
smart combination of request.vars is ok) or for database inserts/updates
(in which case the relatively new DAL callbacks rock - and I use them a
lot).
Either way, there's no syntax to enforce a PK on the table at the database
level with 2 columns involved.
On Thursday, February 28, 2013 12:38:13 PM UTC+1, Alec Taylor wrote:
>
> How do I have unique field combinations in DAL?
>
> So only one of each of these 2-tuples should be allowed:
>
> db.define_table('foo',
> Field('bar_id', db.bar, requires=IS_IN_DB(db, 'bar.id')),
> Field('user_id', db.auth_user, default=auth.user_id, writable=False,
> requires=IS_IN_DB(db, 'auth_user.id')),
> )
>
> Thanks for all suggestions,
>
> Alec Taylor
>
--
---
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/groups/opt_out.