On Sep 2, 2009, at 10:25 AM, mdipierro wrote: > > http://groups.google.com/group/web2py/browse_thread/thread/cd5c13eb8dcb8459#
One caveat--if the original question about doing this "at the model level" means "at the database level", then this solution, which is enforced by the DAL. As the web2py manual points out, DAL-level enforcement is vulnerable to races if the table can have multiple updaters. It would be nice to have access to the underlying database's ability (if it has one) to require uniqueness of a set of fields, since this requirement seems to arise with some frequency (I know I asked the same question a while back). MySQL supports this; I assume that most other databases do as well, though perhaps not universally. (There's precedent for features that aren't universal across all databases-- distributed transactions are an example.) > > On Sep 2, 10:52 am, Benigno <bca...@albendas.com> wrote: >> I figure he means something like: >> Imagine you have several companies working with your applicacion, and >> you have a table with fields like: >> - Company >> - Name >> - ... >> >> Normally you would want to make Name unique, but in this case you >> probably want to make the combination of Company and Name Unique, so >> that a name is unique within each company. >> >> This is something I have also been struggling with, and so far the >> only solution I have found is making a hidden field the combination >> of >> the two, but maybe there is a better way to do this. (This example is >> with IS_NOT_IN_DB but I'd guess the solution would be the same for >> IS_IN_DB). >> >> Tititi, sorry if I have missinterpreted what you wanted to say. >> >> Benigno. >> >> On Sep 2, 5:25 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: >> >>> What do you mean to be validated in this case, can you provide an >>> example? >> >>> On Sep 2, 8:56 am, tititi <briant...@gmail.com> wrote: >> >>>> Hi everyone, >> >>>> I'm trying to keep the duplicate insert logic at the model level >>>> and >>>> would like to find out if there is a way to do this. For example, I >>>> would like a USER_ID and GROUP_ID to be validated before an >>>> insert can >>>> be committed. Using IS_IN_DB with 2 fields work? If there isn't >>>> support for it, is there a chance to add this feature in? Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---