On Thu, Jun 30, 2011 at 6:43 PM, Nick Arnett <[email protected]> wrote:
> > > On Thu, Jun 30, 2011 at 4:15 PM, Anthony <[email protected]> wrote: > >> IS_NOT_IN_DB does take a DAL Set object as the first argument, so you can >> limit the records checked to a particular set within the table (see >> http://web2py.com/book/default/chapter/07#Database-Validators). However, >> I'm not quite sure what you're trying to do here. >> >> I think what he wants is the equivalent of Django's "unique together", > which I'm also trying to figure out. IS_NOT_IN_DB seems to accomplish it, > but is that going to create a unique index on the combined fields? > Otherwise, it will be expensive to do inserts. > Actually, I don't see how NOT_IN_DB can accomplish this, since it is associated with a single field. Do I have to create an extra concatenated field and make it unique? Seems silly, given that's what a database unique index is. In other words, for table foo, if I want fields A, B and C to be unique together, do I have to do this? db.define_table('foo', Field('A'), Field('B'), Field('C'), Field('ABC_unique', unique=True)) And remember to concat A, B, and C into that last field every time I do an insert? I'm missing something here, since this is so simple elsewhere. Nick

