There is a conceptual problem. You can specify the constraint using SQL but when you input a form, how should the error be reported?
The standard practice is to attach a validator to only one of the two fields db.define_table('x', Field('a'),Field('b'),...) db.x.b.requires = IS_NOT_IN_DB(db(db.x.a==request.vars.a), db.b) On Thursday, 18 June 2015 06:25:07 UTC-5, nikalstudioga...@gmail.com wrote: > > Hello, > > I'm hoping it's not a too stupid question as I'm new to web2py. > > I have a table which I fill with data about some games. > Each game has an id but multiple players can possibly have played the same > game. > > So I basically need to have the (game_id, player_id) couple to be unique, > but not each of them separately (one user can play multiple games, and same > game can be used for multiple users). > > Is there a way to specify that ? > > My table is currently like : > db.define_table("table", > Field("game_id"), > Field("user_id", 'reference auth_user', > default=auth.user_id), > Field("player_name"), > Field("start_date", type="datetime"), > Field("duration_sec", type="integer"), > Field("finish_place", type="integer"), > ) > > Thanks in advance, > NiKAL > -- 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.